Spaces:
Sleeping
Sleeping
import gradio as gr | |
import requests | |
import logging | |
# Configure logging | |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | |
def make_api_call(authorization_key, prompt, phone_number): | |
logging.info(f"Making API call with prompt: {prompt} and phone number: {phone_number}") | |
headers = { | |
'Authorization': authorization_key | |
} | |
data = { | |
"phone_number": phone_number, | |
"from": None, | |
"task": prompt, | |
"model": "enhanced", | |
"language": "eng", | |
"voice": "maya", | |
"voice_settings": {}, | |
"local_dialing": False, | |
"max_duration": 12, | |
"answered_by_enabled": False, | |
"wait_for_greeting": False, | |
"record": False, | |
"amd": False, | |
"interruption_threshold": 100, | |
"temperature": None, | |
"transfer_list": {}, | |
"metadata": {}, | |
"pronunciation_guide": [], | |
"start_time": None, | |
"request_data": {}, | |
"tools": [], | |
"webhook": None | |
} | |
response = requests.post('https://api.bland.ai/v1/calls', json=data, headers=headers) | |
logging.info(f"API call response: {response.json()}") | |
return response.json() | |
interface = gr.Interface( | |
fn=make_api_call, | |
inputs=[ | |
gr.Textbox(label="API Key", placeholder="Enter your API Key, e.g., sk-n 路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路路"), | |
gr.Textbox(label="Task", lines=4, placeholder="Describe the task for the chat agent"), | |
gr.Textbox(label="Phone Number", placeholder="Enter phone number in international format, e.g., +1234567890") | |
], | |
outputs="json", | |
description="Create your bland.ai account if you don't have one yet through [this link](https://app.bland.ai/signup). After creating your account, you can find your API key under the 'API Key' tab in your dashboard settings [here](https://app.bland.ai/dashboard?page=settings)." | |
) | |
interface.launch() |