Skip to content
Merged
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
cd075fd
[fix] bump prerelease version in pyproject.toml
actions-user Oct 10, 2024
272794e
[fix] bump prerelease version in pyproject.toml
actions-user Oct 10, 2024
e8f8444
[fix] bump prerelease version in pyproject.toml
actions-user Oct 10, 2024
ec89d7d
Fix docker image (#138)
diogoazevedo15 Oct 10, 2024
111c54f
[fix] bump prerelease version in pyproject.toml
actions-user Oct 10, 2024
a555c40
Fix docker image (#139)
diogoazevedo15 Oct 10, 2024
2f0f482
[fix] bump prerelease version in pyproject.toml
actions-user Oct 10, 2024
f06f595
Add llmstudio docs (#136)
diogoazevedo15 Oct 15, 2024
57ea379
[fix] bump prerelease version in pyproject.toml
actions-user Oct 15, 2024
d95c337
docs: update ollama.mdx
eltociear Oct 17, 2024
70d007e
[feat] beadrock added to LLM Core
brunoalho99 Oct 25, 2024
077dfd7
[bugfix] datetime
brunoalho99 Oct 26, 2024
4507de4
[feat] tool_calling
brunoalho99 Oct 26, 2024
b651789
[feat] processing langchain tools
brunoalho99 Oct 27, 2024
2a1d6ab
Merge branch 'main' into feat/bedrock
brunoalho99 Nov 5, 2024
7e6043c
feat: add ci for modules
diogoncalves Nov 4, 2024
6cc7000
chore: bump versions
diogoncalves Nov 6, 2024
4bc5e1c
feat: adapt develop actions
diogoncalves Nov 6, 2024
285e868
fix: github actions
diogoncalves Nov 6, 2024
324c08d
fix: github actions dev
diogoncalves Nov 6, 2024
3ed9d80
[fix] bump prerelease version in pyproject.toml
actions-user Nov 6, 2024
9006b78
[feat] bedrock agent with langchain and langgraph
brunoalho99 Nov 6, 2024
3d65f0a
[chore] remove print
brunoalho99 Nov 6, 2024
fcfe33e
[feat] bedrock mapper
brunoalho99 Nov 8, 2024
48c5113
[chore] clean unused variable
brunoalho99 Nov 8, 2024
49a402d
[feat] bedrock arguments added
brunoalho99 Nov 8, 2024
20e7abe
[feat] bedrock anthropic
brunoalho99 Nov 11, 2024
fd0bb6a
[bugfix] import corrected
brunoalho99 Nov 11, 2024
7bfacd0
[feat] module added
brunoalho99 Nov 11, 2024
7ad9c7e
[bugfix] async methods corrected
brunoalho99 Nov 12, 2024
51790d7
Create chore.yml
MiNeves00 Nov 12, 2024
b324888
Merge branch 'main' into patch-1
MiNeves00 Nov 12, 2024
072981e
CHORE: Create chore.yml (#172)
MiNeves00 Nov 12, 2024
02d2c6f
[feat] async methods corrected
brunoalho99 Nov 14, 2024
aa5f25a
[fastapi] version bump
brunoalho99 Nov 14, 2024
b7c42bb
[bugfix] new release
brunoalho99 Nov 14, 2024
2e537b6
[feat] code refactor
brunoalho99 Nov 14, 2024
1e73f1d
[feat] function calling
brunoalho99 Nov 16, 2024
6e809dd
[chore] remove async duplicated code from openai
brunoalho99 Nov 17, 2024
2a027b0
[chore] remove duplicated code from azure
brunoalho99 Nov 17, 2024
add329f
docs: update ollama.mdx (#159)
MiNeves00 Nov 18, 2024
fdf84e4
[chore] removed unnecessary code
brunoalho99 Nov 18, 2024
bf1b277
[bugfix] processing more than one tool
brunoalho99 Nov 18, 2024
d5c985d
[feat] test added to langchain integration
brunoalho99 Nov 18, 2024
4b037c7
Merge branch 'develop' into feat/bedrock
brunoalho99 Nov 18, 2024
eda7b4e
Merge branch 'feat/bedrock' into feature/vertexai-refactor
brunoalho99 Nov 18, 2024
2448e27
feat: update ci for libs
diogoncalves Nov 18, 2024
5bb4ad0
feat: update dev workflow
diogoncalves Nov 18, 2024
103383f
[bugfix] get cost using langchain wrapper
brunoalho99 Nov 19, 2024
b1d3a3e
[bugfix] azure init with kwargs
brunoalho99 Nov 19, 2024
9a0d831
Merge branch 'feat/bedrock' into feature/vertexai-refactor
brunoalho99 Nov 19, 2024
6f8f132
fix: workflow
diogoncalves Nov 19, 2024
1216453
chore: bump versions
diogoncalves Nov 19, 2024
27f113a
chore: fix typo
diogoncalves Nov 19, 2024
ddde4c4
chore: name workflow
diogoncalves Nov 19, 2024
42217fd
Merge branch 'main' into develop
diogoncalves Nov 19, 2024
94a19ae
[chore] solve pr comments
brunoalho99 Nov 19, 2024
b689ceb
[chore] normalize return
brunoalho99 Nov 19, 2024
e577f8b
Providers Refactor (#175)
brunoalho99 Nov 19, 2024
a3df3fb
Merge branch 'feat/bedrock' into develop
diogoncalves Nov 19, 2024
1494bd7
Merge branch 'feat/bedrock' into develop
diogoncalves Nov 19, 2024
c700a00
Merge branch 'main' into develop
diogoncalves Nov 19, 2024
9d3c754
fix: workflow
diogoncalves Nov 19, 2024
d4a4ed1
fix: workflow
diogoncalves Nov 19, 2024
7f19ec5
fix: dev workflow
diogoncalves Nov 20, 2024
13d1ed9
fix: workflow dev
diogoncalves Nov 20, 2024
94cfc4b
fix: workflow dev
diogoncalves Nov 20, 2024
5bb0f6b
fix: dev workflow
diogoncalves Nov 20, 2024
19ce260
[fix] bump prerelease version in pyproject.toml
actions-user Nov 20, 2024
c27bb93
fix: dev workflow
diogoncalves Nov 20, 2024
36ab3b0
[chore] updated python dotenv
brunoalho99 Nov 20, 2024
c257e04
[chore] update dotenv in proxy
brunoalho99 Nov 20, 2024
93da5bc
[fix] bump prerelease version in pyproject.toml
actions-user Nov 21, 2024
3c6be06
feat: main workflow to bump automatically alpha versions
diogoncalves Nov 21, 2024
21074f1
chore: bump versions
diogoncalves Nov 21, 2024
991caed
chore: update lock files
diogoncalves Nov 21, 2024
505a0fc
Merge branch 'main' into develop
diogoncalves Nov 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 21 additions & 62 deletions .github/workflows/upload-pypi-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ on:
type: choice
description: "Choose the library to deploy (note: it points to develop branch only)"
options:
- llmstudio
- llmstudio-core
- llmstudio-proxy
- llmstudio-tracker
- ./libs/llmstudio
- ./libs/core
- ./libs/proxy
- ./libs/tracker
target_version:
description: "Target version (e.g., 1.1.0)"
required: true
Expand All @@ -20,14 +20,6 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
env:
MODULE_PATH: |
${{
inputs.library == 'llmstudio' && './libs/llmstudio' ||
inputs.library == 'llmstudio-core' && './libs/core' ||
inputs.library == 'llmstudio-proxy' && './libs/proxy' ||
inputs.library == 'llmstudio-tracker' && './libs/tracker'
}}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -47,49 +39,38 @@ jobs:
run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}

- name: Check PyPI for Target Version
working-directory: ${{ env.MODULE_PATH }}
working-directory: ${{ inputs.library }}
id: check-version
run: |
TARGET_VERSION="${{ github.event.inputs.target_version }}"
PACKAGE_NAME=${{ inputs.library }}
PACKAGE_NAME=$(poetry version | awk '{print $1}')
RESPONSE=$(curl -s "https://pypi.org/pypi/$PACKAGE_NAME/json" || echo "{}")
echo "$RESPONSE" | jq -r '.releases | keys[]' > all_versions.txt
if grep -qx "$TARGET_VERSION" all_versions.txt; then
echo "exists=true" >> $GITHUB_ENV
else
echo "exists=false" >> $GITHUB_ENV
fi

# Step 4: Decide on the next alpha version
- name: Determine Next Alpha Version
id: determine-version
run: |
if [[ "${{ env.exists }}" == "true" ]]; then
if grep -qx "$TARGET_VERSION" all_versions.txt; then
echo "Error: Version ${{ github.event.inputs.target_version }} already exists on PyPI."
exit 1
fi
BASE_VERSION="${{ github.event.inputs.target_version }}"
PACKAGE_NAME=${{ inputs.library }}
ALPHA_VERSIONS=$(grep -E "^$BASE_VERSIONa[0-9]+$" all_versions.txt | sort -V || true)
if [[ -z "$ALPHA_VERSIONS" ]]; then
NEW_VERSION="${BASE_VERSION}a0"

NEXT_ALPHA=$(grep "^${TARGET_VERSION}a[0-9]*$" all_versions.txt | sort -V | tail -n 1 | awk -F'a' '{print $2}')

if [[ -z "$NEXT_ALPHA" ]]; then
NEW_VERSION="${TARGET_VERSION}a0"
else
LATEST_ALPHA=$(echo "$ALPHA_VERSIONS" | tail -n 1)
NEXT_ALPHA_NUM=$(( $(echo "$LATEST_ALPHA" | grep -oE '[0-9]+$') + 1 ))
NEW_VERSION="${BASE_VERSION}a${NEXT_ALPHA_NUM}"
NEW_VERSION="${TARGET_VERSION}a$((NEXT_ALPHA + 1))"
fi
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
echo "Determined new version: $NEW_VERSION"

- name: Build and publish to PyPI as development release
working-directory: ${{ env.MODULE_PATH }}
working-directory: ${{ inputs.library }}
run: |
poetry version ${{ env.new_version }}
poetry build
poetry publish

- name: Commit and push updated pyproject.toml
working-directory: ${{ env.MODULE_PATH }}
working-directory: ${{ inputs.library }}
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
Expand All @@ -98,43 +79,21 @@ jobs:
git push

- name: Wait for PyPI to update
working-directory: ${{ env.MODULE_PATH }}
working-directory: ${{ inputs.library }}
run: |
VERSION=$(poetry version --short)
echo "Checking for ${{ github.event.inputs.library }}==$VERSION on PyPI..."
PACKAGE_NAME=$(poetry version | awk '{print $1}')
echo "Checking for $PACKAGE_NAME==$VERSION on PyPI..."
for i in {1..10}; do
if python -m pip install ${{ github.event.inputs.library }}==${VERSION} --dry-run >/dev/null 2>&1; then
echo "Package ${{ github.event.inputs.library }}==${VERSION} is available on PyPI."
if python -m pip install $PACKAGE_NAME==${VERSION} --dry-run >/dev/null 2>&1; then
echo "Package $PACKAGE_NAME==${VERSION} is available on PyPI."
break
else
echo "Package ${{ github.event.inputs.library }}==${VERSION} not available yet. Waiting 15 seconds..."
echo "Package $PACKAGE_NAME==${VERSION} not available yet. Waiting 15 seconds..."
sleep 15
fi
if [ $i -eq 10 ]; then
echo "Package did not become available in time."
exit 1
fi
done

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract version for tagging Docker image
working-directory: ${{ env.MODULE_PATH }}
id: get_version
run: echo "VERSION=$(poetry version --short)" >> $GITHUB_ENV

- name: Build Docker images
working-directory: ./deploy
run: |
make version=${{ env.VERSION }} build-${{ github.event.inputs.library }}

- name: Push Docker images
run: |
docker push tensoropsai/${{ github.event.inputs.library }}:${{ env.VERSION }}
160 changes: 160 additions & 0 deletions docs/how-to/deploy-on-gcp/deploy-on-google-cloud-platform.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
Learn how to deploy LLMstudio as a containerized application on Google Kubernetes Engine and make calls from a local repository.


## Prerequisites
To follow this guide you need to have the following set-up:

- A **project** on google cloud platform.
- **Kubernetes Engine** API enabled on your project.
- **Kubernetes Engine Admin** role for the user performing the guide.

## Deploy LLMstudio

This example demonstrates a public deployment. For a private service accessible only within your enterprise infrastructure, deploy it within your own Virtual Private Cloud (VPC).
<Steps>
<Step title="Navigate to Kubernetes Engine">
Begin by navigating to the Kubernetes Engine page.
</Step>
<Step title="Select Deploy">
Go to **Workloads** and **Create a new Deployment**.
<Frame>
<img src="how-to/deploy-on-gcp/step-2.png" />
</Frame>
</Step>
<Step title="Name Your Deployment">
Rename your project. We will call the one in this guide **llmstudio-on-gcp**.
<Frame>
<img src="how-to/deploy-on-gcp/step-3.png" />
</Frame>
</Step>
<Step title="Select Your Cluster">
Choose between **creating a new cluster** or **using an existing cluster**.
For this guide, we will create a new cluster and use the default region.
<Frame>
<img src="how-to/deploy-on-gcp/step-4.png" />
</Frame>
</Step>
<Step title="Proceed to Container Details">
Once done done with the **Deployment configuration**, proceed to **Container details**.
</Step>
<Step title="Set Image Path">
In the new container section, select **Existing container image**.


Copy the path to LLMstudio's image available on Docker Hub.
```bash Image Path
tensoropsai/llmstudio:latest
```
Set it as the **Image path** to your container.
<Frame>
<img src="how-to/deploy-on-gcp/step-6.png" />
</Frame>
</Step>
<Step title="Set Environment Variables">
Configure the following mandatory environment variables:
| Environment Variable | Value |
|----------------------------|-----------|
| `LLMSTUDIO_ENGINE_HOST` | 0.0.0.0 |
| `LLMSTUDIO_ENGINE_PORT` | YOUR_DESIRED_PORT |
| `LLMSTUDIO_TRACKING_HOST` | 0.0.0.0 |
| `LLMSTUDIO_TRACKING_PORT` | YOUR_DESIRED_PORT |

Additionally, set the `GOOGLE_API_KEY` environment variable to enable calls to Google's Gemini models.
<Tip>Refer to **SDK/LLM/Providers** for instructions on setting up other providers.</Tip>

<Frame>
<img src="how-to/deploy-on-gcp/step-7.png" />
</Frame>

</Step>
<Step title="Proceed to Expose (Optional)">
After configuring your container, proceed to **Expose (Optional)**.
</Step>
<Step title="Expose Ports">
Select **Expose deployment as a new service** and leave the first item as is.

<Frame>
<img src="how-to/deploy-on-gcp/step-9-1.png" />
</Frame>

Add two other items, and expose the ports defined in the **Set Environment Variables** step.

<Frame>
<img src="how-to/deploy-on-gcp/step-9-2.png" />
</Frame>
</Step>
<Step title="Deploy">
After setting up and exposing the ports, press **Deploy**.
<Check>You have successfully deployed **LLMstudio on Google Cloud Platform**!</Check>
</Step>

</Steps>

## Make a Call
Now let's make a call to our LLMstudio instance on GCP!



<Steps>
<Step title="Set Up Project">
Setup a simple project with this two files:
1. `simple-call.ipynb`
2. `.env`
</Step>

<Step title="Set Up Files">
<Tabs>
<Tab title=".env">

Go to your newly deployed **Workload**, scroll to the **Exposing services** section, and take note of the Host of your endpoint.
<Frame>
<img src="how-to/deploy-on-gcp/step-env.png" />
</Frame>

Create your `.env` file with the following:

```env .env
LLMSTUDIO_ENGINE_HOST = "YOUR_HOST"
LLMSTUDIO_ENGINE_PORT = "YOUR_ENGINE_PORT"
LLMSTUDIO_TRACKING_HOST = "YOUR_TRACKING_PORT"
LLMSTUDIO_TRACKING_PORT = "YOUR_HOST"
```

<Check>You are done seting up you **.env** file!</Check>




</Tab>
<Tab title="simple-call.ipynb">
Start by importing llmstudio:
```python 1st cell
from llmstudio import LLM
```

Set up your LLM. We will be using `gemini-1.5-flash` for this guide.
```python 2nd cell
llm = LLM('vertexai/gemini-1.5-flash')
```

Chat with your model.
```python 3rd cell
llm.chat('Hello!')
print(response.chat_output)
```

<Frame>
<img src="how-to/deploy-on-gcp/step-llmstudio-call.png" />
</Frame>


<Check>You are done calling llmstudio on GCP!</Check>

</Tab>

</Tabs>
</Step>


</Steps>

Binary file added docs/how-to/deploy-on-gcp/step-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/how-to/deploy-on-gcp/step-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/how-to/deploy-on-gcp/step-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/how-to/deploy-on-gcp/step-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/how-to/deploy-on-gcp/step-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/how-to/deploy-on-gcp/step-7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/how-to/deploy-on-gcp/step-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/how-to/deploy-on-gcp/step-9-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/how-to/deploy-on-gcp/step-9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/how-to/deploy-on-gcp/step-env.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@
"baseUrl": "http://localhost:8000"
}
}

86 changes: 86 additions & 0 deletions docs/sdk/llm/chat.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
Make chat calls using your LLM.

## Parameters
The llm.chat method can have the following parameters.
| Parameter | Type | Description |
|-------------------|--------|-----------------------------------------------------------------------------|
| `input ` | str | The input message to send to the chat model. |
| `is_stream` | bool | The temperature parameter for the model. |
| `**kwargs` | dict | Additional parameters to pass to the chat model. |

<Check>Refer to your provider-specific documentation for additional kwargs you can use.</Check>

## Returns
| Output | Type | Description |
|-------------------|--------|-----------------------------------------------------------------------------|
| `ChatCompletion` | object | A chat completion object in the OpenAI format + metrics computed by LLMstudio.|


## Usage
Here's how to use `.chat()` to make calls to your LLM.

<Steps>
<Step>
Start by importing LLM.
```python
from llmstudio import LLM
```
</Step>
<Step >
Set up an LLM from your desired provider.
```python
llm = LLM('openai/gpt-4o')
```
</Step>
<Step>
Create your message. Your message can be a simple `string` or a message in the `OpenAI format`.

<Tabs>
<Tab title="String format">
```python
message = "Hello, how are you today?"
```
</Tab>
<Tab title="OpenAI format">
```python
message = [
{"role": "system", "content": "You are a helpfull assistant."},
{"role": "user", "content": "Hello, how are you today?"}
]
```
</Tab>
</Tabs>

</Step>
<Step>

<Tabs>
<Tab title="Non-stream response">
Get your response.
```python
response = llm.chat(message)
```

Vizualize your response.
```python
print(response)
```
</Tab>
<Tab title="Stream response">
Get your response.
```python
response = llm.chat(message, is_stream = True)
```

Vizualize your response.
```python
for chunk in response:
print(chunk)
```
</Tab>
</Tabs>

<Check>You are done chating with your **LLMstudio LLM**!</Check>
</Step>
</Steps>

Loading
Loading