Spaces:
Paused
Paused
Clément Simon
commited on
Commit
•
1319662
1
Parent(s):
b664be2
fixed: os getenv
Browse files- app.py +4 -3
- static/layout.html +4 -0
- static/mistral.png +0 -0
- weather.py +2 -2
app.py
CHANGED
@@ -34,14 +34,14 @@ def create_env_file():
|
|
34 |
f.write(f"{secret}={secret_value}\n")
|
35 |
|
36 |
# Hugging face space secret retrieval:
|
37 |
-
production =
|
38 |
if production:
|
39 |
create_env_file()
|
40 |
|
41 |
|
42 |
# Load environment variables
|
43 |
load_dotenv()
|
44 |
-
api_key = os.
|
45 |
client = MistralClient(api_key=api_key)
|
46 |
model = 'mistral-small'
|
47 |
|
@@ -101,6 +101,8 @@ def create_world_map(lat, lon):
|
|
101 |
return fig
|
102 |
|
103 |
|
|
|
|
|
104 |
def chat_with_mistral(user_input):
|
105 |
messages = [ChatMessage(role="user", content=user_input)]
|
106 |
|
@@ -255,7 +257,6 @@ async def home(
|
|
255 |
|
256 |
return templates.TemplateResponse("layout.html", {"request": request, "user_profile": user_profile, "weather": weather, "map_html": map_html})
|
257 |
|
258 |
-
|
259 |
class ChatInput(BaseModel):
|
260 |
user_input: str
|
261 |
|
|
|
34 |
f.write(f"{secret}={secret_value}\n")
|
35 |
|
36 |
# Hugging face space secret retrieval:
|
37 |
+
production = False
|
38 |
if production:
|
39 |
create_env_file()
|
40 |
|
41 |
|
42 |
# Load environment variables
|
43 |
load_dotenv()
|
44 |
+
api_key = os.getenv('MISTRAL_API_KEY')
|
45 |
client = MistralClient(api_key=api_key)
|
46 |
model = 'mistral-small'
|
47 |
|
|
|
101 |
return fig
|
102 |
|
103 |
|
104 |
+
|
105 |
+
|
106 |
def chat_with_mistral(user_input):
|
107 |
messages = [ChatMessage(role="user", content=user_input)]
|
108 |
|
|
|
257 |
|
258 |
return templates.TemplateResponse("layout.html", {"request": request, "user_profile": user_profile, "weather": weather, "map_html": map_html})
|
259 |
|
|
|
260 |
class ChatInput(BaseModel):
|
261 |
user_input: str
|
262 |
|
static/layout.html
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
<link rel="stylesheet" href="/static/style.css" />
|
|
|
|
|
4 |
<header>
|
5 |
<nav>
|
6 |
<ul class="menus">
|
@@ -33,6 +35,8 @@
|
|
33 |
<li class="main"><span>Menus</span></li>
|
34 |
<li class="submenu">
|
35 |
<a href="#">Chat</a>
|
|
|
|
|
36 |
<div id="chat">
|
37 |
<input
|
38 |
type="text"
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
<link rel="stylesheet" href="/static/style.css" />
|
4 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
5 |
+
|
6 |
<header>
|
7 |
<nav>
|
8 |
<ul class="menus">
|
|
|
35 |
<li class="main"><span>Menus</span></li>
|
36 |
<li class="submenu">
|
37 |
<a href="#">Chat</a>
|
38 |
+
<!-- add mistral.png -->
|
39 |
+
<img src="/static/mistral.png" alt="Mistral" class="mistral" />
|
40 |
<div id="chat">
|
41 |
<input
|
42 |
type="text"
|
static/mistral.png
ADDED
weather.py
CHANGED
@@ -10,8 +10,8 @@ load_dotenv()
|
|
10 |
|
11 |
|
12 |
def get_weather(city, date):
|
13 |
-
agro_api_key = os.
|
14 |
-
opencage_api_key = os.
|
15 |
|
16 |
# On récupère les lat et lon de la ville
|
17 |
geocode_url = f"https://api.opencagedata.com/geocode/v1/json?q={city}&key={opencage_api_key}"
|
|
|
10 |
|
11 |
|
12 |
def get_weather(city, date):
|
13 |
+
agro_api_key = os.getenv("AGRO_API_KEY")
|
14 |
+
opencage_api_key = os.getenv("OPENCAGE_API_KEY")
|
15 |
|
16 |
# On récupère les lat et lon de la ville
|
17 |
geocode_url = f"https://api.opencagedata.com/geocode/v1/json?q={city}&key={opencage_api_key}"
|