-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from mindsdb/staging
Release 2.4.4
- Loading branch information
Showing
11 changed files
with
141 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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={'model_name': model_name, 'openai_api_key': open_ai_key}, | ||
params={'openai_api_key': open_ai_key}) | ||
|
||
# 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?' | ||
answer = agent.completion([{'question': question, 'answer': None}]) | ||
print(answer.content) | ||
|
||
con.databases.drop(database.name) | ||
con.agents.drop(agent.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from uuid import uuid4 | ||
|
||
from openai import OpenAI | ||
from mindsdb_sdk.utils.mind import create_mind | ||
import os | ||
|
||
|
||
# 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' | ||
|
||
|
||
# Connect to MindsDB LiteLLM proxy. | ||
client = OpenAI( | ||
api_key=MINDSDB_API_KEY, | ||
base_url=base_url | ||
) | ||
|
||
# create a database mind | ||
mind = create_mind( | ||
name = f'my_house_data_mind_{uuid4().hex}', | ||
description= 'House Sales', | ||
base_url= base_url, | ||
api_key= MINDSDB_API_KEY, | ||
model= model_name, | ||
data_source_type='postgres', | ||
data_source_connection_args={ | ||
'user': 'demo_user', | ||
'password': 'demo_password', | ||
'host': 'samples.mindsdb.com', | ||
'port': '5432', | ||
'database': 'demo', | ||
'schema': 'demo_data' | ||
} | ||
) | ||
|
||
# Actually pass in our tool to get a SQL completion. | ||
completion = client.chat.completions.create( | ||
model=mind.name, | ||
messages=[ | ||
{'role': 'user', 'content': 'How many 2 bedroom houses sold in 2008?'} | ||
], | ||
stream=False | ||
) | ||
|
||
print(completion.choices[0].message.content) |
This file was deleted.
Oops, something went wrong.
71 changes: 0 additions & 71 deletions
71
examples/using_mindsdb_inference_with_text2sql_using_tools.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
__title__ = 'mindsdb_sdk' | ||
__package_name__ = 'mindsdb_sdk' | ||
__version__ = '2.4.3' | ||
__version__ = '2.4.4' | ||
__description__ = "MindsDB Python SDK, provides an SDK to use a remote mindsdb instance" | ||
__email__ = "[email protected]" | ||
__author__ = 'MindsDB Inc' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.