Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +69 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""Untitled28.ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colab.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1RXiaLZbGoqx1ruqk83PmIcGRn3gdbbwq
|
8 |
+
"""
|
9 |
+
|
10 |
+
!pip install streamlit
|
11 |
+
!pip install google-generativeai
|
12 |
+
|
13 |
+
import streamlit as st
|
14 |
+
import google.generativeai as genai
|
15 |
+
import requests
|
16 |
+
|
17 |
+
# GenAI API anahtarını yapılandır
|
18 |
+
genai.configure(api_key='AIzaSyDmDtBz5Q96JzzJHojpyR2m0KJ44TKaZm8')
|
19 |
+
|
20 |
+
# Holiday API anahtarını ayarla
|
21 |
+
holiday_api_key = 'a7ffbb5e-34de-4934-a4fa-3a35de185646'
|
22 |
+
holiday_api_url = 'https://holidayapi.com/v1/holidays'
|
23 |
+
|
24 |
+
# Uygulama başlığı
|
25 |
+
st.title('Chat with Me')
|
26 |
+
|
27 |
+
# GenAI modeli ve sohbet başlatma
|
28 |
+
model = genai.GenerativeModel('gemini-1.5-pro-latest')
|
29 |
+
chat = model.start_chat(history=[])
|
30 |
+
|
31 |
+
# Kullanıcıdan soru al
|
32 |
+
soru = st.text_input('You:')
|
33 |
+
|
34 |
+
if st.button('Ask'):
|
35 |
+
response = chat.send_message(soru)
|
36 |
+
st.write(response.text)
|
37 |
+
st.write(chat.history)
|
38 |
+
|
39 |
+
if st.button('New Chat'):
|
40 |
+
chat = model.start_chat(history=chat.history)
|
41 |
+
|
42 |
+
st.header('Holiday Information')
|
43 |
+
date = st.text_input('Enter a date (YYYY-MM-DD):')
|
44 |
+
country = st.text_input('Enter a country code (e.g., US, TR):')
|
45 |
+
|
46 |
+
if st.button('Get Holidays'):
|
47 |
+
if date and country:
|
48 |
+
params = {
|
49 |
+
'key': holiday_api_key,
|
50 |
+
'country': country,
|
51 |
+
'year': date.split('-')[0],
|
52 |
+
'month': date.split('-')[1],
|
53 |
+
'day': date.split('-')[2]
|
54 |
+
}
|
55 |
+
response = requests.get(holiday_api_url, params=params)
|
56 |
+
|
57 |
+
if response.status_code == 200:
|
58 |
+
holidays = response.json().get('holidays', [])
|
59 |
+
if holidays:
|
60 |
+
st.write('Holidays on', date, 'in', country + ':')
|
61 |
+
for holiday in holidays:
|
62 |
+
st.write(holiday['name'])
|
63 |
+
else:
|
64 |
+
st.write('No holidays found on this date in the specified country.')
|
65 |
+
else:
|
66 |
+
st.write('Error:', response.status_code)
|
67 |
+
else:
|
68 |
+
st.write('Please enter both a date and a country code.')
|
69 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
requests
|
3 |
+
google-generativeai
|