Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: openrouter integration, added additional async methods #539

Closed
wants to merge 30 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1fdc77a
feat: openrouter, qdrant async
vikyw89 Jul 8, 2024
a9e82cc
fix: default config to {}
vikyw89 Jul 8, 2024
cc3c858
fix: baseurl on openrouter
vikyw89 Jul 8, 2024
bb261ce
fix: increase max token for openrouter
vikyw89 Jul 8, 2024
6b6a4e5
fix: embeddings dimension on qdrant
vikyw89 Jul 8, 2024
66b9861
feat: embedding dimension from async
vikyw89 Jul 8, 2024
1c65f7d
fix: better async session for sqlalchemy
vikyw89 Jul 9, 2024
64e506f
feat: set max row to be fed to llm on summary to only 10 rows
vikyw89 Jul 9, 2024
3277bc1
feat: added retry on openrouter asubmit prompt
vikyw89 Jul 9, 2024
fed4acf
chore: rename parsed_df
vikyw89 Jul 9, 2024
096a1ed
feat: increased pool size on mysql
vikyw89 Jul 9, 2024
a9f9fd0
feat: session mysql fix on concurrent
vikyw89 Jul 9, 2024
e03795a
feat: session concurrent user fix
vikyw89 Jul 9, 2024
2efe9ed
feat: expose api key
vikyw89 Jul 10, 2024
92a44d4
feat: expose model through param
vikyw89 Jul 10, 2024
9e10d91
feat: return asyncengine upon mysql connect to cleanup
vikyw89 Jul 10, 2024
267f128
feat: overflow 0
vikyw89 Jul 10, 2024
86b8691
feat: increase max overflow and timeout
vikyw89 Jul 10, 2024
e5e5d77
feat: add pool timeout
vikyw89 Jul 10, 2024
2e2171a
feat: improve agenerate summary prompt
vikyw89 Jul 11, 2024
09be181
feat: improved prompt on agenerate summary
vikyw89 Jul 11, 2024
f00986c
feat: async with instead of finally
vikyw89 Jul 11, 2024
de953ea
feat: expose client on a connect to mysql
vikyw89 Jul 12, 2024
6909531
fix: aconnectmysql
vikyw89 Jul 12, 2024
0365e7c
fix: port
vikyw89 Jul 12, 2024
31188d6
feat: improve sql agent summary
vikyw89 Jul 19, 2024
180233b
fix: agenerate summary prompt
vikyw89 Jul 19, 2024
e12df61
perf: faster ageneratesql
vikyw89 Aug 7, 2024
f6f7225
fix: prevent context overflow on intermediate sql
vikyw89 Aug 7, 2024
1728c2f
perf: fix lost in the middle on long context
vikyw89 Aug 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
Prev Previous commit
Next Next commit
feat: expose model through param
  • Loading branch information
vikyw89 committed Jul 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 92a44d47867617f8dea67dd01c503e755798a612
35 changes: 13 additions & 22 deletions src/vanna/openrouter/openrouter_chat.py
Original file line number Diff line number Diff line change
@@ -23,20 +23,15 @@ def __init__(
):
VannaBase.__init__(self, config=config)
# default parameters - can be overrided using config
self.temperature = 0.3
self.max_tokens = 4000
self.temperature = config.get("temperature", 0.7)
self.max_tokens = config.get("max_tokens", 500)
self.client = client
self.aclient = aclient

if "temperature" in config:
self.temperature = config["temperature"]

if "max_tokens" in config:
self.max_tokens = config["max_tokens"]

if "api_key" in config:
self.client.api_key = config["api_key"]
self.aclient.api_key = config["api_key"]
self.model = config.get(
"model", os.getenv("OPENROUTER_MODEL", "deepseek/deepseek-chat")
)
self.client.api_key = config.get("api_key", os.getenv("OPENROUTER_API_KEY"))
self.aclient.api_key = config.get("api_key", os.getenv("OPENROUTER_API_KEY"))

def system_message(self, message: str) -> Any:
return {"role": "system", "content": message}
@@ -88,9 +83,7 @@ def submit_prompt(
return ""

@retry
async def asubmit_prompt(
self, prompt, model: str = "deepseek/deepseek-chat", **kwargs
) -> str:
async def asubmit_prompt(self, prompt, **kwargs) -> str:
if prompt is None:
raise Exception("Prompt is None")

@@ -103,9 +96,9 @@ async def asubmit_prompt(
for message in prompt:
num_tokens += len(message["content"]) / 4

print(f"Using model {model} for {num_tokens} tokens (approx)")
print(f"Using model {self.model} for {num_tokens} tokens (approx)")
response = await self.aclient.chat.completions.create(
model=model,
model=self.model,
messages=prompt,
max_tokens=self.max_tokens,
stop=None,
@@ -128,9 +121,7 @@ async def asubmit_prompt(

return ""

async def astream_submit_prompt(
self, prompt, model: str = "deepseek/deepseek-chat", **kwargs
) -> AsyncIterable[str]:
async def astream_submit_prompt(self, prompt, **kwargs) -> AsyncIterable[str]:
if prompt is None:
raise Exception("Prompt is None")

@@ -143,9 +134,9 @@ async def astream_submit_prompt(
for message in prompt:
num_tokens += len(message["content"]) / 4

print(f"Using model {model} for {num_tokens} tokens (approx)")
print(f"Using model {self.model} for {num_tokens} tokens (approx)")
stream = await self.aclient.chat.completions.create(
model=model,
model=self.model,
messages=prompt,
max_tokens=self.max_tokens,
stop=None,