├── requirements.txt ├── README.md └── app.py /requirements.txt: -------------------------------------------------------------------------------- 1 | g4f[all] 2 | gradio 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AI Assistant Chatbot 2 | 3 | This project creates an AI-powered assistant chatbot using GPT4Free and interfaces it with a Gradio web UI for easy interaction. 4 | 5 | ## Setup 6 | 7 | 1. Clone the repository to your local machine. 8 | 2. Install the required Python packages with `pip install -r requirements.txt`. 9 | 3. Run the chatbot with `app.py`. 10 | 11 | ## Usage 12 | 13 | After running the script, a Gradio interface will open in your default web browser. Type your questions or commands into the input box, and the chatbot will respond. 14 | 15 | ## Contributing 16 | 17 | Feel free to fork the project, make changes, and submit pull requests if you have suggestions for improvements! 18 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | # Import necessary libraries 2 | from g4f.client import Client 3 | import gradio as gr 4 | 5 | # Initialize the G4F client 6 | client = Client() 7 | 8 | # Define the function for generating creative writing prompts 9 | def generate_writing_prompt(user_input): 10 | response = client.chat.completions.create( 11 | model="gpt-3.5-turbo", 12 | messages=[{"role": "user", "content": user_input}], 13 | ) 14 | return response.choices[0].message.content 15 | 16 | # Gradio userinterface... 17 | interface = gr.Interface( 18 | fn=generate_writing_prompt, 19 | inputs=gr.Textbox(lines=3, placeholder="Enter a genre, tone, or initial plot point..."), 20 | outputs="text", 21 | title="Creative Writing Assistant 📝", 22 | description="Unleash your creativity! Get inspired with unique story ideas, prompts, and plot twists.", 23 | theme="huggingface", 24 | examples=[ 25 | ["A story about a lost civilization discovering technology."], 26 | ["Compose a poem about the changing seasons."], 27 | ["A suspense thriller set in an abandoned mansion."], 28 | ] 29 | ) 30 | 31 | 32 | # Launch the interface 33 | if __name__ == "__main__": 34 | interface.launch() --------------------------------------------------------------------------------