Spaces:
Sleeping
Sleeping
File size: 2,312 Bytes
3936a1d f46f011 f9b771d f46f011 3936a1d 13fe244 3936a1d 10b03c2 3936a1d c5254fa 3936a1d c5254fa 3936a1d c5254fa 3936a1d c5254fa 3936a1d c5254fa 3936a1d f9b771d 3936a1d f9b771d 3936a1d f9b771d 3936a1d f9b771d |
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 |
# -*- coding: utf-8 -*-
"""Untitled28.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1RXiaLZbGoqx1ruqk83PmIcGRn3gdbbwq
"""
import streamlit as st
import google.generativeai as genai
import requests
# GenAI API anahtarını yapılandır
genai.configure(api_key='AIzaSyDmDtBz5Q96JzzJHojpyR2m0KJ44TKaZm8')
# Holiday API anahtarını ayarla
holiday_api_key = 'a7ffbb5e-34de-4934-a4fa-3a35de185646'
holiday_api_url = 'https://holidayapi.com/v1/holidays'
# Uygulama başlığı
st.title('Test Deneme')
# GenAI modeli ve sohbet başlatma
model = genai.GenerativeModel('gemini-1.5-pro-latest')
chat = model.start_chat(history=[])
# Kullanıcıdan soru al
soru = st.text_input('You:')
if st.button('Ask'):
response = chat.send_message(soru)
st.write(response.text)
st.write(chat.history)
if st.button('New Chat'):
chat = model.start_chat(history=chat.history)
# Holiday API ile tatil bilgilerini almak için tarih ve ülke girişi
st.header('Holiday Information')
date = st.text_input('Enter a date (YYYY-MM-DD):')
country = st.text_input('Enter a country code (e.g., US, TR):')
if st.button('Get Holidays'):
if date and country:
params = {
'key': holiday_api_key,
'country': country,
'year': date.split('-')[0],
'month': date.split('-')[1],
'day': date.split('-')[2]
}
# API'ye istek yap ve yanıtı al
response = requests.get(holiday_api_url, params=params)
# API isteğini ve yanıtını logla
st.write('API Request URL:', response.url)
st.write('API Response Status Code:', response.status_code)
st.write('API Response JSON:', response.json())
if response.status_code == 200:
holidays = response.json().get('holidays', [])
if holidays:
st.write('Holidays on', date, 'in', country + ':')
for holiday in holidays:
st.write(holiday['name'])
else:
st.write('No holidays found on this date in the specified country.')
else:
st.write('Error:', response.status_code)
else:
st.write('Please enter both a date and a country code.')
|