-
Notifications
You must be signed in to change notification settings - Fork 0
/
Findlaw_agent.py
119 lines (94 loc) · 5.68 KB
/
Findlaw_agent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import requests
from dotenv import load_dotenv
import os
from speech_processing import SpeechProcessing
from openai_agent import OpenAIAgent
load_dotenv()
class FindLawAgent:
def __init__(self):
# self.api_key = os.getenv("WEATHER_API_KEY")
# self.base_url = "http://api.weatherapi.com/v1/current.json"
self.openai_agent = OpenAIAgent()
self.speech_processing = SpeechProcessing()
self.location = "none"
self.Practices = "none"
#------------------------------------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------------------------------
def handal_command(self, command):
location = self.openai_agent.extract_information("location", command)
Practices = self.openai_agent.extract_Legal_information(command)
if location == "none" or Practices == "none":
if location == "none":
self.get_location(command)
elif Practices=="none":
self.get_Practices(command)
else:
# weather_data = self.get_weather(location)
# self.process_weather(weather_data)
print(location, Practices)
quit()
#------------------------------------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------------------------------
def command_condition(self, command):
if self.location == "none" or self.Practices == "none":
if self.location == "none":
self.get_location(command)
elif self.Practices=="none":
self.get_Practices(command)
else:
# weather_data = self.get_weather(location)
# self.process_weather(weather_data)
print(self.location, self.Practices)
quit()
#------------------------------------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------------------------------
def get_location(self, command):
self.speech_processing.speak("please specify the location for me to give you relavent firm result.")
location = self.speech_processing.listen()
location = self.openai_agent.extract_information("location", location)
self.location = location
print(self.location, self.Practices)
if location and location != "none":
# weather_data=self.get_weather(location)
self.command_condition(command)
else:
self.speech_processing.speak("i can't find the specified location. please try again.")
#------------------------------------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------------------------------
def get_Practices(self, command):
self.speech_processing.speak("please specify the Practice Area for me to give you relavent firms.")
Practices = self.speech_processing.listen()
Practices = self.openai_agent.extract_Legal_information(command)
self.Practices = Practices
print(self.location, self.Practices)
if Practices and Practices != "none":
# weather_data=self.get_weather(Practices)
self.command_condition(command)
else:
self.speech_processing.speak("i can't find the specified Practice areas. please try again.")
#------------------------------------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------------------------------
# def process_legal(self, data):
# if data:
# weather_message = f"Currently in {data['location']}, the weather condition is : {data['condition']}, and the temperature is : {data['temperature']} degrees."
# self.speech_processing.speak(weather_message)
# else:
# self.speech_processing.speak("I couden't retreave the weather information please try again.")
#------------------------------------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------------------------------
# def get_legal(self, location):
# params = {
# 'key': self.api_key,
# 'q' : location,
# 'aqi' : 'no'
# }
# response = requests.get(self.base_url, params=params)
# if response.status_code != 200:
# return None
# data = response.json()
# weather_data= {
# 'location': data['location']['name'],
# 'condition': data['current']['condition']['text'],
# 'temperature': data['current']['temp_c']
# }
# return weather_data