# -*- 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.')