Spaces:
Runtime error
Runtime error
Update LLM config
Browse files
app.py
CHANGED
|
@@ -10,26 +10,12 @@ from autogen.agentchat.contrib.retrieve_assistant_agent import RetrieveAssistant
|
|
| 10 |
from autogen.agentchat.contrib.retrieve_user_proxy_agent import RetrieveUserProxyAgent, PROMPT_DEFAULT
|
| 11 |
|
| 12 |
|
| 13 |
-
def setup_configurations(
|
| 14 |
-
config_list = autogen.
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
"gpt-4",
|
| 20 |
-
"gpt4",
|
| 21 |
-
"gpt-4-32k",
|
| 22 |
-
"gpt-4-32k-0314",
|
| 23 |
-
"gpt-35-turbo",
|
| 24 |
-
"gpt-3.5-turbo",
|
| 25 |
-
}
|
| 26 |
-
},
|
| 27 |
-
)
|
| 28 |
-
assert len(config_list) > 0
|
| 29 |
-
print("models to use: ", [config_list[i]["model"] for i in range(len(config_list))])
|
| 30 |
-
|
| 31 |
-
return config_list
|
| 32 |
-
|
| 33 |
|
| 34 |
def initialize_agents(config_list, docs_path=None):
|
| 35 |
if docs_path is None:
|
|
@@ -97,25 +83,13 @@ def get_description_text():
|
|
| 97 |
|
| 98 |
This demo shows how to use the RetrieveUserProxyAgent and RetrieveAssistantAgent to build a chatbot.
|
| 99 |
|
| 100 |
-
#### [GitHub](https://github.com/microsoft/autogen)
|
| 101 |
-
|
| 102 |
-
LLM configure file should contain OpenAI, Azure OpenAI or other openai compatible models, for example:
|
| 103 |
-
```
|
| 104 |
-
[
|
| 105 |
-
{
|
| 106 |
-
"engine": "gpt-35-turbo",
|
| 107 |
-
"model": "gpt-3.5-turbo",
|
| 108 |
-
"api_base": "https://xxx.openai.azure.com",
|
| 109 |
-
"api_type": "azure",
|
| 110 |
-
"api_version": "2023-05-15",
|
| 111 |
-
"api_key": "xxx",
|
| 112 |
-
}
|
| 113 |
-
]
|
| 114 |
-
```
|
| 115 |
"""
|
| 116 |
|
| 117 |
global config_list, assistant, ragproxyagent
|
| 118 |
-
|
|
|
|
|
|
|
| 119 |
with gr.Blocks() as demo:
|
| 120 |
gr.Markdown(get_description_text())
|
| 121 |
chatbot = gr.Chatbot(
|
|
@@ -135,10 +109,9 @@ with gr.Blocks() as demo:
|
|
| 135 |
|
| 136 |
def upload_file(file):
|
| 137 |
global config_list, assistant, ragproxyagent
|
| 138 |
-
|
| 139 |
-
assistant, ragproxyagent = initialize_agents(config_list)
|
| 140 |
|
| 141 |
-
upload_button = gr.UploadButton("Click to Upload
|
| 142 |
upload_button.upload(upload_file, upload_button)
|
| 143 |
|
| 144 |
clear = gr.ClearButton([txt_input, chatbot])
|
|
|
|
| 10 |
from autogen.agentchat.contrib.retrieve_user_proxy_agent import RetrieveUserProxyAgent, PROMPT_DEFAULT
|
| 11 |
|
| 12 |
|
| 13 |
+
def setup_configurations():
|
| 14 |
+
config_list = autogen.config_list_from_models(model_list=["gpt-4", "gpt-3.5-turbo", "gpt-35-turbo"])
|
| 15 |
+
if len(config_list) > 0:
|
| 16 |
+
return [config_list[0]]
|
| 17 |
+
else:
|
| 18 |
+
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
def initialize_agents(config_list, docs_path=None):
|
| 21 |
if docs_path is None:
|
|
|
|
| 83 |
|
| 84 |
This demo shows how to use the RetrieveUserProxyAgent and RetrieveAssistantAgent to build a chatbot.
|
| 85 |
|
| 86 |
+
#### [GitHub](https://github.com/microsoft/autogen) [Discord](https://discord.gg/pAbnFJrkgZ) [Docs](https://microsoft.github.io/autogen/) [Paper](https://arxiv.org/abs/2308.08155)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
"""
|
| 88 |
|
| 89 |
global config_list, assistant, ragproxyagent
|
| 90 |
+
config_list = setup_configurations()
|
| 91 |
+
assistant, ragproxyagent = initialize_agents(config_list) if config_list else (None, None)
|
| 92 |
+
|
| 93 |
with gr.Blocks() as demo:
|
| 94 |
gr.Markdown(get_description_text())
|
| 95 |
chatbot = gr.Chatbot(
|
|
|
|
| 109 |
|
| 110 |
def upload_file(file):
|
| 111 |
global config_list, assistant, ragproxyagent
|
| 112 |
+
update_context_url(file.name)
|
|
|
|
| 113 |
|
| 114 |
+
upload_button = gr.UploadButton("Click to Upload Document", file_types=[f".{i}" for i in TEXT_FORMATS], file_count="single")
|
| 115 |
upload_button.upload(upload_file, upload_button)
|
| 116 |
|
| 117 |
clear = gr.ClearButton([txt_input, chatbot])
|