Update app.py
Browse files
app.py
CHANGED
@@ -53,17 +53,27 @@ def generate_prompts_for_object(object_name):
|
|
53 |
|
54 |
|
55 |
# === Agent Setup ===
|
|
|
56 |
text_to_image_client = InferenceClient("m-ric/text-to-image")
|
57 |
-
|
58 |
text_to_image_tool = TextToImageTool(client=text_to_image_client)
|
59 |
-
|
60 |
search_tool = DuckDuckGoSearchResults()
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
|
|
67 |
agent = create_react_agent(llm=llm, tools=[text_to_image_tool, search_tool])
|
68 |
agent_executor = AgentExecutor(agent=agent, tools=[text_to_image_tool, search_tool], verbose=True)
|
69 |
|
|
|
53 |
|
54 |
|
55 |
# === Agent Setup ===
|
56 |
+
# Set up the tools
|
57 |
text_to_image_client = InferenceClient("m-ric/text-to-image")
|
|
|
58 |
text_to_image_tool = TextToImageTool(client=text_to_image_client)
|
|
|
59 |
search_tool = DuckDuckGoSearchResults()
|
60 |
|
61 |
+
# Load a public, token-free model locally via transformers pipeline
|
62 |
+
text_gen_pipeline = pipeline("text-generation", model="tiiuae/falcon-7b-instruct", max_new_tokens=512)
|
63 |
+
|
64 |
+
# Wrap pipeline into a LangChain LLM
|
65 |
+
class PipelineLLM(LLM):
|
66 |
+
def _call(self, prompt, stop=None):
|
67 |
+
output = text_gen_pipeline(prompt)[0]["generated_text"]
|
68 |
+
return output
|
69 |
+
|
70 |
+
@property
|
71 |
+
def _llm_type(self):
|
72 |
+
return "pipeline_llm"
|
73 |
+
|
74 |
+
llm = PipelineLLM()
|
75 |
|
76 |
+
# Create agent and executor
|
77 |
agent = create_react_agent(llm=llm, tools=[text_to_image_tool, search_tool])
|
78 |
agent_executor = AgentExecutor(agent=agent, tools=[text_to_image_tool, search_tool], verbose=True)
|
79 |
|