skjaini commited on
Commit
d9259e4
·
verified ·
1 Parent(s): 0ca5145

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -2,7 +2,7 @@ import streamlit as st
2
  from crewai import Crew, Agent, Task, Process
3
  from langchain_core.tools import Tool
4
  from langchain_community.tools import DuckDuckGoSearchRun
5
- from langchain_community.llms import HuggingFaceHub
6
  import datetime
7
  import os
8
 
@@ -44,9 +44,9 @@ def create_ai_news_crew():
44
  verbose=True,
45
  allow_delegation=False,
46
  tools=[search_tool],
47
- llm=HuggingFaceHub(
48
- repo_id="deepseek-ai/DeepSeek-Coder-33B-Instruct",
49
- task="text-generation", # Explicitly set the task
50
  model_kwargs={"temperature": 0.5, "max_new_tokens": 1024, "repetition_penalty": 1.2},
51
  huggingfacehub_api_token=huggingfacehub_api_token,
52
  )
@@ -61,9 +61,9 @@ def create_ai_news_crew():
61
  on AI developments quickly.""",
62
  verbose=True,
63
  allow_delegation=False,
64
- llm=HuggingFaceHub(
65
- repo_id="deepseek-ai/DeepSeek-Coder-33B-Instruct",
66
- task="text-generation", # Explicitly set the task
67
  model_kwargs={"temperature": 0.2, "max_new_tokens": 1024, "repetition_penalty": 1.2},
68
  huggingfacehub_api_token=huggingfacehub_api_token,
69
  )
@@ -126,7 +126,7 @@ def main():
126
 
127
  except Exception as e:
128
  st.error(f"An error occurred: {e}")
129
- st.error("Please check your API key and ensure you have set up the environment correctly.")
130
 
131
 
132
  if __name__ == "__main__":
 
2
  from crewai import Crew, Agent, Task, Process
3
  from langchain_core.tools import Tool
4
  from langchain_community.tools import DuckDuckGoSearchRun
5
+ from langchain_community.llms import HuggingFaceEndpoint # Changed to HuggingFaceEndpoint
6
  import datetime
7
  import os
8
 
 
44
  verbose=True,
45
  allow_delegation=False,
46
  tools=[search_tool],
47
+ llm=HuggingFaceEndpoint( # Use HuggingFaceEndpoint
48
+ endpoint_url="https://api-inference.huggingface.co/models/deepseek-ai/DeepSeek-Coder-33B-Instruct", #Use correct end point
49
+ task="text-generation",
50
  model_kwargs={"temperature": 0.5, "max_new_tokens": 1024, "repetition_penalty": 1.2},
51
  huggingfacehub_api_token=huggingfacehub_api_token,
52
  )
 
61
  on AI developments quickly.""",
62
  verbose=True,
63
  allow_delegation=False,
64
+ llm=HuggingFaceEndpoint( # Use HuggingFaceEndpoint
65
+ endpoint_url="https://api-inference.huggingface.co/models/deepseek-ai/DeepSeek-Coder-33B-Instruct", #Use correct endpoint
66
+ task="text-generation",
67
  model_kwargs={"temperature": 0.2, "max_new_tokens": 1024, "repetition_penalty": 1.2},
68
  huggingfacehub_api_token=huggingfacehub_api_token,
69
  )
 
126
 
127
  except Exception as e:
128
  st.error(f"An error occurred: {e}")
129
+ st.error("Please check your API key, endpoint URL and ensure you have set up the environment correctly.") #Added endpoint url check
130
 
131
 
132
  if __name__ == "__main__":