Skip to content

Commit

Permalink
Merge pull request #149 from mindsdb/main
Browse files Browse the repository at this point in the history
Release 3.1.1
  • Loading branch information
tmichaeldb authored Aug 19, 2024
2 parents 8e17af6 + 9a23f3e commit d89f343
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 14 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Release

on:
push:
branches:
- stable
release:
types: [published]

jobs:
test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: PR workflow
on:
pull_request:
branches:
- stable
- staging
- main

jobs:
test:
Expand Down
4 changes: 2 additions & 2 deletions examples/using_agents_with_streaming_with_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

agent.add_file('./data/tokaido-rulebook.pdf', 'rule book for the board game Tokaido')

question = "what are the rules for the game takaido?"
question = "what are the rules for the game tokaido?"

# Stream the completion
completion_stream = agent.completion_stream([{'question': question, 'answer': None}])
Expand All @@ -30,4 +30,4 @@
full_response += chunk

print("\n\nFull response:")
print(full_response)
print(full_response)
54 changes: 54 additions & 0 deletions examples/using_agents_with_text2sql_streaming.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import mindsdb_sdk
from uuid import uuid4
import os

con = mindsdb_sdk.connect()

open_ai_key = os.getenv('OPENAI_API_KEY')
model_name = 'gpt-4'

# Now create an agent that will use the model we just created.
agent = con.agents.create(name=f'mindsdb_sql_agent_{model_name}_{uuid4().hex}',
model='gpt-4')


# Set up a Postgres data source with our new agent.
data_source = 'postgres'
connection_args = {
"user": "demo_user",
"password": "demo_password",
"host": "samples.mindsdb.com",
"port": "5432",
"database": "demo",
"schema": "demo_data"
}
description = 'mindsdb demo database'
database = con.databases.create(
f'mindsdb_sql_agent_datasource_{uuid4().hex}',
data_source,
connection_args
)

# Actually connect the agent to the datasource.
agent.add_database(database.name, [], description)


question = 'How many three-bedroom houses were sold in 2008?'

completion_stream = agent.completion_stream([{'question': question, 'answer': None}])

# Process the streaming response
full_response = ""
for chunk in completion_stream:
print(chunk) # Print the entire chunk for debugging
if isinstance(chunk, dict):
if 'output' in chunk:
full_response += chunk['output']
elif isinstance(chunk, str):
full_response += chunk

print("\n\nFull response:")
print(full_response)

con.databases.drop(database.name)
con.agents.drop(agent.name)
6 changes: 1 addition & 5 deletions examples/using_database_mind_text2sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
# Load MindsDB API key from environment variable. or set it here.
MINDSDB_API_KEY = os.getenv('MINDSDB_API_KEY')

# Set the model name for mind to use
model_name = 'gpt-4'

# Set the base URL for the MindsDB LiteLLM proxy.
base_url = 'https://ai.dev.mindsdb.com'
base_url = 'https://llm.mdb.ai'


# Connect to MindsDB LiteLLM proxy.
Expand Down Expand Up @@ -42,7 +39,6 @@
api_key= MINDSDB_API_KEY,
name = f'my_house_data_mind_{uuid4().hex}',
data_source_configs=[pg_config],
model= model_name
)

# Actually pass in our tool to get a SQL completion.
Expand Down
2 changes: 1 addition & 1 deletion mindsdb_sdk/__about__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__title__ = 'mindsdb_sdk'
__package_name__ = 'mindsdb_sdk'
__version__ = '3.1.0'
__version__ = '3.1.1'
__description__ = "MindsDB Python SDK, provides an SDK to use a remote mindsdb instance"
__email__ = "[email protected]"
__author__ = 'MindsDB Inc'
Expand Down
2 changes: 1 addition & 1 deletion mindsdb_sdk/connectors/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def agent_completion(self, project: str, name: str, messages: List[dict]):
@_try_relogin
def agent_completion_stream(self, project: str, name: str, messages: List[dict]):
url = self.url + f'/api/projects/{project}/agents/{name}/completions/stream'
stream = requests.post(url, json={'messages': messages}, stream=True)
stream = self.session.post(url, json={'messages': messages}, stream=True)
client = SSEClient(stream)
for chunk in client.events():
# Stream objects loaded from SSE events 'data' param.
Expand Down

0 comments on commit d89f343

Please sign in to comment.