CryptoScoutv1 commited on
Commit
5c11d86
·
verified ·
1 Parent(s): 08c8668

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +95 -1
app.py CHANGED
@@ -1,3 +1,97 @@
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
- gr.load("models/cognitivecomputations/dolphin-2.6-mixtral-8x7b").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import os
3
+ from crewai import Agent, Task, Crew, Process
4
+ from langchain.tools import DuckDuckGoSearchRun
5
+ from langchain.agents import load_tools
6
+ from langchain_openai import ChatOpenAI
7
+ from langchain.llms import ollama
8
+ from openai import OpenAI
9
+ from langchain_google_genai import ChatGoogleGenerativeAI
10
+ from crypto_info import CryptoTools
11
  import gradio as gr
12
 
13
+ # Setting up the environment variable for the Google API key
14
+ api_gemini = 'AIzaSyB4feCeVxvjfd6a6L1jtaV_NHUMSh0MGQk'
15
+ os.environ["api_gemini"] = api_gemini
16
+
17
+ # Function to run the Crew AI logic
18
+ def run_crew_ai(query):
19
+ # Initialize the ChatGoogleGenerativeAI model with verbose set to False
20
+ llm2 = ChatGoogleGenerativeAI(
21
+ model="gemini-pro", verbose=False, temperature=0.1, google_api_key=api_gemini
22
+ )
23
+
24
+ # Initialize tools
25
+ search_tool = DuckDuckGoSearchRun()
26
+ crypto_tool = CryptoTools()
27
+ human_tools = load_tools(["human"])
28
+
29
+ # Define Agents with verbose set to False
30
+ researcher = Agent(
31
+ role='Researcher',
32
+ goal='Identify new and relevant cryptocurrencies based on user criteria using the internet tool',
33
+ tools=[search_tool],
34
+ verbose=False,
35
+ allow_delegation=False,
36
+ llm=llm2
37
+ )
38
+
39
+ info_gatherer = Agent(
40
+ role='Information Gatherer',
41
+ goal='Collect detailed information about the identified cryptocurrency using the search tool.',
42
+ tools=[search_tool],
43
+ verbose=False,
44
+ allow_delegation=False,
45
+ llm=llm2
46
+ )
47
+
48
+ formatter = Agent(
49
+ role='Formatter',
50
+ goal='Structure all gathered information into a clear, concise format.',
51
+ verbose=False,
52
+ allow_delegation=False,
53
+ llm=llm2
54
+ )
55
+
56
+ # Define Tasks
57
+ research_task = Task(
58
+ description=f'Search the internet for a cryptocurrency that matches the user\'s prompt. Here is the prompt: "{query}"',
59
+ agent=researcher
60
+ )
61
+
62
+ gather_task = Task(
63
+ description='Gather all relevant information about the identified cryptocurrency including a summary, todays price, todays market capilization,offical URL.',
64
+ agent=info_gatherer
65
+ )
66
+
67
+ format_task = Task(
68
+ description='Structure the gathered information in a list structure with all the relevant details neat and user friendly',
69
+ agent=formatter
70
+ )
71
+
72
+ # Define and run the Crew
73
+ crew = Crew(
74
+ agents=[researcher, info_gatherer, formatter],
75
+ tasks=[research_task, gather_task, format_task],
76
+ process=Process.sequential,
77
+ verbose=0 # Minimize verbose output
78
+ )
79
+ result = crew.kickoff()
80
+
81
+ return result
82
+
83
+ # Gradio Interface Setup
84
+ def gradio_interface(query):
85
+ return run_crew_ai(query)
86
+
87
+ # Create a Gradio interface with an input textbox and output text
88
+ interface = gr.Interface(
89
+ fn=gradio_interface,
90
+ inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your query here..."),
91
+ outputs="text",
92
+ title="Crew AI Cryptocurrency Researcher",
93
+ description="Enter a query to research cryptocurrencies using Crew AI."
94
+ )
95
+
96
+ # Launch the Gradio interface
97
+ interface.launch()