Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,55 @@ for await (const chunk of chunks) {

```

### Python

Works in Google Colab

```Python
## uncomment for Google Colab
#!pip install anyio
#!pip install openai

from anyio import run
from openai import AsyncOpenAI

# Configuration
server = 'gemini'
base_url = f'https://abcdefghijklmnopqrstuvwxyz.lambda-url.us-west-2.on.aws/{server}/v1/'
api_key = 'GEMINI_API_KEY' # Use the same token as in your YAML

# Create OpenAI client
openai = AsyncOpenAI(
base_url=base_url,
api_key=api_key,
)

async def main():
model = 'gemini-2.0-flash'
prompt = 'Tell me a joke.'

params = {
'model': model,
'messages': [{'role': 'user', 'content': prompt}],
'stream': True,
}

# Create streaming chat completion
chunks = await openai.chat.completions.create(**params)
response = ''

# Iterate through streaming chunks
async for chunk in chunks:
if chunk.choices and chunk.choices[0].delta.content:
content = chunk.choices[0].delta.content
response += content
print(content, end='', flush=True)

print(f"\n\nFull response: {response}")

# Run the async function
await main()```

### Test

```
Expand All @@ -165,6 +214,7 @@ Include the configuration file containing the api tokens of the supported LLM se

```
$ npm run build
$ cp -R node_modules dist/
$ cp openai_servers.yaml dist/
```

Expand Down
5 changes: 4 additions & 1 deletion openai_servers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ predibase:
ollama:
url: http://127.0.0.1:11434/v1
token: ollama_token
model: mistral:latest
model: mistral:latest
gemini:
token: YOUR_GEMINI_API_KEY
model: gemini-2.0-flash
Loading