Spaces:
Running
Running
Niki Zhang
commited on
Update chatbox.py
Browse files- chatbox.py +5 -11
chatbox.py
CHANGED
@@ -22,11 +22,9 @@ from transformers import pipeline, BlipProcessor, BlipForConditionalGeneration,
|
|
22 |
os.environ["OPENAI_API_VERSION"] = '2020-11-07'
|
23 |
|
24 |
VISUAL_CHATGPT_PREFIX = """
|
25 |
-
I want you act as
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
You have access to the following tools:"""
|
30 |
|
31 |
|
32 |
# TOOLS:
|
@@ -140,7 +138,7 @@ def build_chatbot_tools(load_dict):
|
|
140 |
return tools
|
141 |
|
142 |
class ConversationBot:
|
143 |
-
def __init__(self, tools, api_key=""
|
144 |
# load_dict = {'VisualQuestionAnswering':'cuda:0', 'ImageCaptioning':'cuda:1',...}
|
145 |
llm = OpenAIChat(model_name="gpt-4o", temperature=0.7, openai_api_key=api_key, model_kwargs={"api_version": "2020-11-07"})
|
146 |
self.llm = llm
|
@@ -149,7 +147,6 @@ class ConversationBot:
|
|
149 |
self.current_image = None
|
150 |
self.point_prompt = ""
|
151 |
self.global_prompt = ""
|
152 |
-
self.save_history=save_history
|
153 |
self.agent = initialize_agent(
|
154 |
self.tools,
|
155 |
self.llm,
|
@@ -174,10 +171,7 @@ class ConversationBot:
|
|
174 |
return ans
|
175 |
|
176 |
def run_text(self, text, state, aux_state):
|
177 |
-
|
178 |
-
self.agent.memory.buffer = ""
|
179 |
-
else:
|
180 |
-
self.agent.memory.buffer = cut_dialogue_history(self.agent.memory.buffer, keep_last_n_words=500)
|
181 |
if self.point_prompt != "":
|
182 |
Human_prompt = f'\nHuman: {self.point_prompt}\n'
|
183 |
AI_prompt = 'Ok'
|
@@ -229,4 +223,4 @@ if __name__ == '__main__':
|
|
229 |
clear.click(lambda: [], None, auxwindow)
|
230 |
clear.click(lambda: [], None, state)
|
231 |
clear.click(lambda: [], None, aux_state)
|
232 |
-
demo.launch(server_name="0.0.0.0", server_port=args.port, share=True)
|
|
|
22 |
os.environ["OPENAI_API_VERSION"] = '2020-11-07'
|
23 |
|
24 |
VISUAL_CHATGPT_PREFIX = """
|
25 |
+
I want you to act as an art connoisseur, providing in-depth and insightful analysis on various artworks. Your responses should reflect a deep understanding of art history, techniques, and cultural contexts, offering users a rich and nuanced perspective.
|
26 |
|
27 |
+
You can engage in natural-sounding conversations, generate human-like text based on input, and provide relevant, coherent responses on art-related topics."""
|
|
|
|
|
28 |
|
29 |
|
30 |
# TOOLS:
|
|
|
138 |
return tools
|
139 |
|
140 |
class ConversationBot:
|
141 |
+
def __init__(self, tools, api_key=""):
|
142 |
# load_dict = {'VisualQuestionAnswering':'cuda:0', 'ImageCaptioning':'cuda:1',...}
|
143 |
llm = OpenAIChat(model_name="gpt-4o", temperature=0.7, openai_api_key=api_key, model_kwargs={"api_version": "2020-11-07"})
|
144 |
self.llm = llm
|
|
|
147 |
self.current_image = None
|
148 |
self.point_prompt = ""
|
149 |
self.global_prompt = ""
|
|
|
150 |
self.agent = initialize_agent(
|
151 |
self.tools,
|
152 |
self.llm,
|
|
|
171 |
return ans
|
172 |
|
173 |
def run_text(self, text, state, aux_state):
|
174 |
+
self.agent.memory.buffer = cut_dialogue_history(self.agent.memory.buffer, keep_last_n_words=500)
|
|
|
|
|
|
|
175 |
if self.point_prompt != "":
|
176 |
Human_prompt = f'\nHuman: {self.point_prompt}\n'
|
177 |
AI_prompt = 'Ok'
|
|
|
223 |
clear.click(lambda: [], None, auxwindow)
|
224 |
clear.click(lambda: [], None, state)
|
225 |
clear.click(lambda: [], None, aux_state)
|
226 |
+
demo.launch(server_name="0.0.0.0", server_port=args.port, share=True)
|