|
| 1 | +# Streaming Chatbot |
| 2 | +This asset is a Python-based chatbot that utilizes Oracle Cloud Infrastructure (OCI) Generative AI services to provide real-time, streaming responses. It is designed to interact with Cohere models available within OCI's Generative AI service. Users interested in leveraging other models, such as those from Meta or Google, can refer to the OCI Generative AI documentation for guidance on integrating these alternatives. |
| 3 | + |
| 4 | +Reviewed: 22.10.2025 |
| 5 | + |
| 6 | +# When to use this asset? |
| 7 | + |
| 8 | +This asset is suitable for developers and organizations aiming to integrate AI-driven conversational interfaces into their applications, particularly when: |
| 9 | + |
| 10 | +- **Real-Time Interaction**: Immediate, dynamic responses are required in a chat interface. |
| 11 | +- **Stateless Processing**: Each user input is processed independently, without context from prior exchanges. |
| 12 | +- **Scalable AI Solutions**: Utilizing OCI's Generative AI services to handle varying loads and complex queries. |
| 13 | + |
| 14 | +# How to use this asset? |
| 15 | + |
| 16 | +To set up and run the `genai-streaming-chatbot`, follow these steps: |
| 17 | + |
| 18 | +1. **Prerequisites**: |
| 19 | + |
| 20 | + - **Python Environment**: Ensure Python 3.6 or later is installed. |
| 21 | + - **OCI Account**: An active Oracle Cloud Infrastructure account with necessary permissions. |
| 22 | + - **API Key**: Generate and configure an API key for authentication. |
| 23 | + |
| 24 | +2. **Installation**: |
| 25 | + |
| 26 | + - **Virtual Environment**: It's recommended to use a virtual environment to manage dependencies. |
| 27 | + |
| 28 | + ```bash |
| 29 | + pip install virtualenv |
| 30 | + virtualenv oci_env |
| 31 | + source oci_env/bin/activate |
| 32 | + ``` |
| 33 | + |
| 34 | + - **Install OCI SDK**: |
| 35 | + |
| 36 | + ```bash |
| 37 | + pip install oci |
| 38 | + ``` |
| 39 | + |
| 40 | +3. **Configuration**: |
| 41 | + |
| 42 | + - **API Key Setup**: Generate an API key pair in the OCI Console and configure it in the `~/.oci/config` file. Ensure the private key has appropriate permissions. |
| 43 | + |
| 44 | + - **Configuration File**: Create a `config` file in the `~/.oci` directory with the necessary details: |
| 45 | + |
| 46 | + ```ini |
| 47 | + [DEFAULT] |
| 48 | + user=ocid1.user.oc1..<unique_ID> |
| 49 | + fingerprint=<your_fingerprint> |
| 50 | + key_file=~/.oci/oci_api_key.pem |
| 51 | + tenancy=ocid1.tenancy.oc1..<unique_ID> |
| 52 | + region=us-ashburn-1 |
| 53 | + ``` |
| 54 | + |
| 55 | +4. **Running the Chatbot**: |
| 56 | + |
| 57 | + - **Script Setup**: Save the chatbot script to a file, e.g., `genai_streaming_chatbot.py`. |
| 58 | + |
| 59 | + - **Execute the Script**: |
| 60 | + |
| 61 | + ```bash |
| 62 | + python genai_streaming_chatbot.py |
| 63 | + ``` |
| 64 | + |
| 65 | + - **Interaction**: Engage with the chatbot by typing messages. Type 'exit' to end the session. |
| 66 | + |
| 67 | +**Note**: This chatbot processes each input independently and does not retain context from previous interactions. To implement a conversational chatbot that maintains context, you would need to manage the conversation history externally by storing previous user inputs and model responses, then appending this history to each new prompt. |
| 68 | + |
| 69 | +# Useful Links |
| 70 | + |
| 71 | +- [OCI Python SDK Documentation](https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/pythonsdk.htm) |
| 72 | + - Comprehensive guide on using the OCI Python SDK. |
| 73 | +- [OCI Generative AI Inference API Documentation](https://docs.oracle.com/en-us/iaas/tools/python/latest/api/generative_ai_inference.html) |
| 74 | + - Detailed information on the Generative AI Inference API. |
| 75 | +- [OCI Generative AI Service](https://docs.oracle.com/en-us/iaas/Content/generative-ai/home.htm) |
| 76 | + - Detailed information on OCI Generative AI Service |
| 77 | + |
| 78 | +# License |
| 79 | + |
| 80 | +Copyright (c) 2025 Oracle and/or its affiliates. |
| 81 | + |
| 82 | +Licensed under the Universal Permissive License (UPL), Version 1.0. |
| 83 | + |
| 84 | +See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE.txt) for more details. |
0 commit comments