Spaces:
Running
Running
Niki Zhang
commited on
Update chatbox.py
Browse files- chatbox.py +5 -2
chatbox.py
CHANGED
@@ -13,11 +13,14 @@ import inspect
|
|
13 |
from langchain.agents.initialize import initialize_agent
|
14 |
from langchain.agents.tools import Tool
|
15 |
from langchain.chains.conversation.memory import ConversationBufferMemory
|
16 |
-
from langchain.llms.openai import
|
17 |
import torch
|
18 |
from PIL import Image, ImageDraw, ImageOps
|
19 |
from transformers import pipeline, BlipProcessor, BlipForConditionalGeneration, BlipForQuestionAnswering
|
20 |
|
|
|
|
|
|
|
21 |
VISUAL_CHATGPT_PREFIX = """
|
22 |
I want you act as Caption Anything Chatbox (short as CATchat), which is designed to be able to assist with a wide range of text and visual related tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. You are able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.
|
23 |
|
@@ -139,7 +142,7 @@ def build_chatbot_tools(load_dict):
|
|
139 |
class ConversationBot:
|
140 |
def __init__(self, tools, api_key="",save_history=False):
|
141 |
# load_dict = {'VisualQuestionAnswering':'cuda:0', 'ImageCaptioning':'cuda:1',...}
|
142 |
-
llm =
|
143 |
self.llm = llm
|
144 |
self.memory = ConversationBufferMemory(memory_key="chat_history", output_key='output')
|
145 |
self.tools = tools
|
|
|
13 |
from langchain.agents.initialize import initialize_agent
|
14 |
from langchain.agents.tools import Tool
|
15 |
from langchain.chains.conversation.memory import ConversationBufferMemory
|
16 |
+
from langchain.llms.openai import OpenAIChat
|
17 |
import torch
|
18 |
from PIL import Image, ImageDraw, ImageOps
|
19 |
from transformers import pipeline, BlipProcessor, BlipForConditionalGeneration, BlipForQuestionAnswering
|
20 |
|
21 |
+
# openai.api_version = '2020-11-07'
|
22 |
+
os.environ["OPENAI_API_VERSION"] = '2020-11-07'
|
23 |
+
|
24 |
VISUAL_CHATGPT_PREFIX = """
|
25 |
I want you act as Caption Anything Chatbox (short as CATchat), which is designed to be able to assist with a wide range of text and visual related tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. You are able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.
|
26 |
|
|
|
142 |
class ConversationBot:
|
143 |
def __init__(self, tools, api_key="",save_history=False):
|
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
|
147 |
self.memory = ConversationBufferMemory(memory_key="chat_history", output_key='output')
|
148 |
self.tools = tools
|