This project showcases how you can use asynchronous streaming with OpenAI assistant and at the same time utilize function calling in FastAPI.
You can read about it in detail in the following blog post: OpenAI Assistant Streaming with Function Calling in FastAPI
This project demonstrates how you can use FastAPI to create a real-time chat interface that communicates with OpenAI's GPT models for automated responses. The application also supports function calling, allowing you to execute commands and retrieve information in real-time.
- Asynchronous streaming for real-time chat communication.
- Function calling for executing commands and retrieving information.
- Integration with OpenAI's GPT models for automated responses.
- Weather information retrieval using the OpenWeather API.
- Text to Speech and Speech to Text using web APIs.
- Chat interface for real-time communication.
- Python 3.8 or higher
- FastAPI
- OpenAI API
- aiohttp, httpx for asynchronous HTTP requests
Refer to requirements.txt for a complete list of dependencies.
- Clone the repository to your local machine.
- Create a virtual environment:
python -m venv env- Activate the virtual environment:
- On Windows:
env\Scripts\activate- On Unix or MacOS:
source env/bin/activate- Install the required packages:
pip install -r requirements.txt- Copy
.env.developmentto.envand adjust the configuration variables as needed. - Ensure you have valid API keys for OpenAI and OpenWeather APIs set in your
.envfile.
- Start the application:
uvicorn main:app --reload- Visit
http://127.0.0.1:8000in your web browser to access the chat interface.
- Use the chat interface to communicate in real-time.
Contributions are welcome! Please feel free to submit pull requests or open issues to suggest improvements or add new features.
