DenverJones commited on
Commit
460bec5
·
verified ·
1 Parent(s): 4186f75

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
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("HF_API_KEY")
10
- HF_MODEL_ID = os.environ.get("HF_MODEL_ID", "google/flan-t5-xxl") # Default model if env var not set
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 # Import the correct class
38
 
39
  llm = HuggingFaceEndpoint(
40
  repo_id=HF_MODEL_ID,
41
- model_kwargs={"temperature": 0.7, "max_new_tokens": 512},
42
- huggingfacehub_api_token=HF_API_KEY, # Still get this from env variable
 
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