Spaces:
Runtime error
Runtime error
[email protected]
commited on
Commit
·
339b260
1
Parent(s):
41ece8b
app.py
CHANGED
@@ -7,10 +7,11 @@ from langchain.chains.conversation.memory import ConversationBufferWindowMemory
|
|
7 |
|
8 |
import os
|
9 |
|
10 |
-
OPENAI_API_KEY=""
|
11 |
-
OPENAI_API_BASE=""
|
|
|
12 |
|
13 |
-
llm=AzureChatOpenAI(deployment_name=
|
14 |
|
15 |
import torch
|
16 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
@@ -32,10 +33,6 @@ def describeImage(image_url):
|
|
32 |
outputs = model.generate(**inputs)
|
33 |
return processor.decode(outputs[0], skip_special_tokens=True)
|
34 |
|
35 |
-
# description = describeImage('https://img.phb123.com/uploads/allimg/151026/7-151026161P2.jpg')
|
36 |
-
|
37 |
-
# description
|
38 |
-
|
39 |
from langchain.tools import BaseTool
|
40 |
|
41 |
class DescribeImageTool(BaseTool):
|
@@ -65,12 +62,3 @@ agent = initialize_agent(
|
|
65 |
)
|
66 |
)
|
67 |
|
68 |
-
image_url = 'https://img.phb123.com/uploads/allimg/151026/7-151026161P2.jpg'
|
69 |
-
agent(f"Describe the following image:\n{image_url}")
|
70 |
-
|
71 |
-
agent(f"How tall this tower looks in the following image:\n{image_url}")
|
72 |
-
|
73 |
-
image_url = 'https://img.phb123.com/uploads/allimg/151026/7-151026161P2.jpg'
|
74 |
-
agent(f"Please describe the following image:\n{image_url}")
|
75 |
-
|
76 |
-
agent.memory.buffer
|
|
|
7 |
|
8 |
import os
|
9 |
|
10 |
+
OPENAI_API_KEY=os.getenv("OPENAI_API_KEY")
|
11 |
+
OPENAI_API_BASE=os.getenv("OPENAI_API_BASE")
|
12 |
+
DEP_NAME=os.getenv("deployment_name")
|
13 |
|
14 |
+
llm=AzureChatOpenAI(deployment_name=DEP_NAME,openai_api_base=OPENAI_API_BASE,openai_api_key=OPENAI_API_KEY,openai_api_version="2023-03-15-preview",model_name="gpt-3.5-turbo")
|
15 |
|
16 |
import torch
|
17 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
|
|
33 |
outputs = model.generate(**inputs)
|
34 |
return processor.decode(outputs[0], skip_special_tokens=True)
|
35 |
|
|
|
|
|
|
|
|
|
36 |
from langchain.tools import BaseTool
|
37 |
|
38 |
class DescribeImageTool(BaseTool):
|
|
|
62 |
)
|
63 |
)
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|