ysharma HF staff commited on
Commit
bf08171
·
1 Parent(s): b3cb545

added search tool

Browse files
Files changed (1) hide show
  1. app.py +8 -16
app.py CHANGED
@@ -29,18 +29,11 @@ from gpt_function_definitions import generate_image, generate_caption, get_news
29
  # Get the value of the openai_api_key from environment variable
30
  openai.api_key = os.getenv("OPENAI_API_KEY")
31
 
32
- #chat = ChatOpenAI(
33
- # #openai_api_key=openai_api_key,
34
- # temperature=1.0,
35
- # streaming=True,
36
- # model='gpt-3.5-turbo-0613'
37
- # )
38
 
39
  #Streaming endpoint
40
  API_URL = "https://api.openai.com/v1/chat/completions" #os.getenv("API_URL") + "/generate_stream"
41
 
42
 
43
-
44
  # TOOLS and FUNCTION CALLING
45
  # Load the tool configs that are needed.
46
  # 'Tool' dataclass wraps functions that accept a single string input and returns a string output.
@@ -68,15 +61,14 @@ tools = [
68
  name="get_news",
69
  description="get top three engilsh news items for a given query, sorted by relevancy"
70
  # coroutine= ... <- you can specify an async method if desired as well
71
- ),]
72
-
73
- # Creating OpenAI functions
74
- # use LangChain tools as OpenAI functions.
75
- #functions = [format_tool_to_openai_function(t) for t in tools]
76
- #functions
77
-
78
- # defining agents using tools and openai functions
79
- #agent = initialize_agent(tools, chat, agent=AgentType.OPENAI_FUNCTIONS, verbose=True)
80
 
81
 
82
  # function calling
 
29
  # Get the value of the openai_api_key from environment variable
30
  openai.api_key = os.getenv("OPENAI_API_KEY")
31
 
 
 
 
 
 
 
32
 
33
  #Streaming endpoint
34
  API_URL = "https://api.openai.com/v1/chat/completions" #os.getenv("API_URL") + "/generate_stream"
35
 
36
 
 
37
  # TOOLS and FUNCTION CALLING
38
  # Load the tool configs that are needed.
39
  # 'Tool' dataclass wraps functions that accept a single string input and returns a string output.
 
61
  name="get_news",
62
  description="get top three engilsh news items for a given query, sorted by relevancy"
63
  # coroutine= ... <- you can specify an async method if desired as well
64
+ ),
65
+ Tool.from_function(
66
+ func=search.run,
67
+ name="Search",
68
+ description="useful for when you need to answer questions about current events"
69
+ # coroutine= ... <- you can specify an async method if desired as well
70
+ ),
71
+ ]
 
72
 
73
 
74
  # function calling