D.A.R.T.H is a powerful streamlit application designed to assist developers in enhancing their coding experience. With a focus on providing valuable resources and aiding in various aspects of coding, D.A.R.T.H offers four key functions to make developers' lives easier.
-
Article Generation:
- D.A.R.T.H can generate articles in English, Yoruba, Igbo, and Hausa. The English version is also synthesized into speech, providing an accessible way to consume information.
-
Code Documentation Generator:
- Simplify the process of creating code documentation. Insert your code, and D.A.R.T.H will generate comprehensive documentation for you.
-
Code Bug Detection and Correction:
- Identify and fix bugs in your code effortlessly. By submitting your code to D.A.R.T.H, it analyzes the content, pinpoints errors, and provides automated fixes.
-
Document Assistant:
- Upload a document, and D.A.R.T.H becomes your knowledgeable assistant. Ask questions about the document, and receive detailed answers in English. The responses are also synthesized into speech for a convenient listening experience.
Follow the instructions below to get started with D.A.R.T.H:
- Python installed
- Streamlit library installed (you can install it using
pip install streamlit) - OPENAI and AZURE API keys
- Clone the repository.
- Navigate to the project directory.
- Install the required dependencies.
pip install -r requirements.txt The app.py file contains a Streamlit app for interacting with various functions of the D.A.R.T.H system. Here's how you can use the Streamlit app:
-
Generate Article and Synthesize Speech:
- Enter text for article generation.
- Select the translation language (English, Yoruba, Igbo, Hausa).
- Click "Generate and Translate" to generate and translate the article.
- Optionally, click "Synthesize Speech" to listen to the synthesized speech.
-
Generate Code Documentation:
- Enter your code in the provided text area.
- Select the programming language from the dropdown.
- Click "Generate Documentation" to generate code documentation.
-
Detect and Fix Bugs:
- Enter your code in the provided text area.
- Select the programming language from the dropdown.
- Click "Detect and Fix Bugs" to identify and fix bugs in the code.
-
D.A.R.T.H Assistant:
- Upload a PDF file.
- Enter your prompt text in the text area.
- Click "Run Assistant" to interact with the OpenAI Assistant.
- View the user and assistant messages, and optionally listen to the synthesized speech.
streamlitfor creating the interactive web app.openailibrary for OpenAI interactions.dotenvfor managing environment variables.
-
Install the required dependencies using
pip install streamlit openai python-dotenvorpip install requirements.txt. -
Create a
.envfile with your OpenAI API and AZURE key. -
Run the Streamlit app using
streamlit run app.py.
Here's an example demonstrating how to use the Streamlit app:
# Install dependencies
pip install streamlit openai python-dotenvstreamlit run app.py
Alternatively, you can email the developers to restart the space so you can run the app in the cloud with our API. Check the description of the repository for more info.
The article_generator function in D.A.R.T.H allows you to generate articles in various languages using OpenAI's GPT-4 model. Here's a breakdown of how it works:
from DARTH import article_generator
# Provide user input and target language
user_input = "Say this is a test"
language = "English"
# Generate the translated article
translated_article = article_generator(user_input, language)print(translated_article)
-
User Input:
- The function takes a user input message as the starting point for generating an article.
-
Language Selection:
- Specify the target language for the article. Supported languages include English, Yoruba, Igbo, and Hausa.
-
Translation:
- Utilizes OpenAI's GPT-4 model to generate a response in the specified language.
-
Translation to Speech:
- Translates the English version into the chosen language and formats the translated article for readability.
openailibrary for GPT-4 model interactions.requestslibrary for making HTTP requests.streamlitfor creating the user interface.dotenvfor managing environment variables.
The generate_code_documentation function in D.A.R.T.H simplifies the process of generating documentation and comments for your codebase. Here's how you can use it:
from DARTH import generate_code_documentationcode_base = """
""" language = "python"
documentation = generate_code_documentation(code_base, language)
print(documentation)
-
Code Input:
- Provide your codebase or function for which you want to generate documentation.
-
Language Specification:
- Specify the programming language of your code (e.g., Python, JavaScript).
-
Documentation Generation:
- The function uses OpenAI's GPT-4 model to generate comprehensive documentation and comments for the provided code.
The detect_and_fix_bugs function in D.A.R.T.H simplifies the process of identifying and fixing bugs or potential issues in your codebase. Here's how you can use it:
from DARTH import detect_and_fix_bugscode_base = """
""" language = "python"
bug_detection_result = detect_and_fix_bugs(code_base, language)
print(bug_detection_result)
-
Code Input:
- Provide your codebase or function for which you want to detect and fix bugs.
-
Language Specification:
- Specify the programming language of your code (e.g., Python, JavaScript).
-
Bug Detection and Fixing:
- The function uses OpenAI's GPT-4 model to analyze the provided code, identify bugs or potential issues, and suggest fixes or improvements.
The run_openai_assistant function in D.A.R.T.H allows you to interact with an OpenAI assistant using a file and prompt text. Here's how you can use it:
from DARTH import run_openai_assistantuploaded_file = open("path/to/your/file.txt", "rb") prompt_text = "Ask a question or provide instructions."
user_messages, assistant_messages = run_openai_assistant(uploaded_file, prompt_text)
print("User Messages:", user_messages) print("Assistant Messages:", assistant_messages)
-
File Upload:
- The function uploads a file to OpenAI, which will be used during the interaction with the OpenAI assistant.
-
Assistant Initialization:
- An OpenAI assistant is created with specific instructions, tools, and a model (gpt-4-1106-preview).
-
Conversation Initiation:
- A conversation thread is established, and an initial message is sent to the assistant with the provided prompt text.
-
Assistant Execution:
- The assistant is run within the context of the conversation thread, and the function periodically checks for completion.
-
Message Retrieval:
- Once the assistant completes the run, the function retrieves and organizes the user and assistant messages from the conversation.
DeepSeeker is an open-source model implemented in the Article Generation for Developers notebook. However, the implementation demonstrated a sluggish performance. To overcome this limitation, we incorporated OpenAI GPT-4 into the system, enhancing the model's speed and responsiveness. The model is still available to be run in the Article Generation for Developers notebook. Using a GPU would incur a wait time of about 5-10 minutes. Using a CPU would incur a wait time of about 10 minutes.
To address the speed constraints, we integrated OpenAI GPT-4 to achieve wait times of 3 minutes or less. This not only accelerates the application's processing but also leverages the advanced capabilities of GPT-4, providing improved efficiency and more accurate outcomes.