Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,12 +2,12 @@ import os
|
|
| 2 |
import yaml
|
| 3 |
import gradio as gr
|
| 4 |
from langchain.agents import initialize_agent, Tool
|
| 5 |
-
from langchain.llms import HuggingFaceHub
|
| 6 |
from langchain.prompts import PromptTemplate
|
|
|
|
| 7 |
|
| 8 |
# Load environment variables
|
| 9 |
-
HF_API_KEY = os.environ.get("
|
| 10 |
-
HF_MODEL_ID = os.environ.get("HF_MODEL_ID", "google/flan-t5-xxl")
|
| 11 |
|
| 12 |
# Load prompt templates
|
| 13 |
with open("prompts.yaml", 'r') as stream:
|
|
@@ -34,12 +34,13 @@ tools = [
|
|
| 34 |
]
|
| 35 |
|
| 36 |
# Initialize the language model
|
| 37 |
-
from langchain_huggingface import HuggingFaceEndpoint
|
| 38 |
|
| 39 |
llm = HuggingFaceEndpoint(
|
| 40 |
repo_id=HF_MODEL_ID,
|
| 41 |
-
|
| 42 |
-
|
|
|
|
| 43 |
)
|
| 44 |
|
| 45 |
# Create the prompt template
|
|
|
|
| 2 |
import yaml
|
| 3 |
import gradio as gr
|
| 4 |
from langchain.agents import initialize_agent, Tool
|
|
|
|
| 5 |
from langchain.prompts import PromptTemplate
|
| 6 |
+
from langchain_huggingface import HuggingFaceEndpoint # Correct import
|
| 7 |
|
| 8 |
# Load environment variables
|
| 9 |
+
HF_API_KEY = os.environ.get("HUGGINGFACEHUB_API_TOKEN") # Correct environment variable name
|
| 10 |
+
HF_MODEL_ID = os.environ.get("HF_MODEL_ID", "google/flan-t5-xxl")
|
| 11 |
|
| 12 |
# Load prompt templates
|
| 13 |
with open("prompts.yaml", 'r') as stream:
|
|
|
|
| 34 |
]
|
| 35 |
|
| 36 |
# Initialize the language model
|
| 37 |
+
from langchain_huggingface import HuggingFaceEndpoint
|
| 38 |
|
| 39 |
llm = HuggingFaceEndpoint(
|
| 40 |
repo_id=HF_MODEL_ID,
|
| 41 |
+
temperature=0.7,
|
| 42 |
+
max_new_tokens=512,
|
| 43 |
+
huggingfacehub_api_token=HF_API_KEY,
|
| 44 |
)
|
| 45 |
|
| 46 |
# Create the prompt template
|