Created
November 22, 2023 15:37
-
-
Save langecrew/53dcc651cff4f9fc3e8512f3b159cfbc to your computer and use it in GitHub Desktop.
Basic test of retrieval with GPT Assistant Agent
This file contains hidden or 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
[ | |
{ | |
"model": "gpt-4", | |
"api_key": "PASTE_YOUR_API_KEY_HERE" | |
}, | |
{ | |
"model": "gpt-4-1106-preview", | |
"api_key": "PASTE_YOUR_API_KEY_HERE" | |
}, | |
{ | |
"model": "gpt-3.5-turbo-1106", | |
"api_key": "PASTE_YOUR_API_KEY_HERE" | |
} | |
] |
This file contains hidden or 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
import logging | |
import os | |
from autogen import config_list_from_json | |
from autogen.agentchat.contrib.gpt_assistant_agent import GPTAssistantAgent | |
from autogen import UserProxyAgent | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.WARNING) | |
config_list = config_list_from_json( | |
env_or_file="OAI_CONFIG_LIST", | |
filter_dict={ | |
"model": [ | |
"gpt-4-1106-preview", | |
] | |
} | |
) | |
assistant_id = None | |
llm_config = { | |
"config_list": config_list, | |
"assistant_id": assistant_id, | |
"tools": [ | |
{ | |
"type": "retrieval" | |
} | |
], | |
"file_ids": ["PASTE_YOUR_FILE_ID(S)_HERE"] | |
} | |
gpt_assistant = GPTAssistantAgent(name="assistant", | |
instructions="You are adapt at summarizing python notebooks", | |
llm_config=llm_config) | |
user_proxy = UserProxyAgent(name="user_proxy", | |
code_execution_config=False, | |
is_termination_msg=lambda msg: "TERMINATE" in msg["content"], | |
human_input_mode="ALWAYS") | |
user_proxy.initiate_chat(gpt_assistant, message="I gave you a python notebook. Could you please describe it?") | |
gpt_assistant.delete_assistant() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment