Lädt...


🔧 Consult with AI Neurologist with Lyzr Automata, Streamlit and OpenAI


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

In the ever-evolving landscape of healthcare technology, the integration of artificial intelligence (AI) has revolutionized various medical domains. One such application is the development of consultation tools that aid healthcare professionals in providing efficient and accurate assessments. In this blog post, we'll explore how to build a Neurology Consultant app using Streamlit and OpenAI, enabling streamlined interactions and insights.

Lyzr.ai

Check out the Lyzr.ai community on Discord – hang out with 338 other members and enjoy free voice and text chat.

favicon discord.com

Setting Up the Environment
Imports:

pip install lyzr_automata streamlit
import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent,Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from PIL import Image
from dotenv import load_dotenv
import os
from prompt import example
load_dotenv()
api = os.getenv("OPENAI_API_KEY")

Imports necessary libraries like streamlit, dotenv, PIL, and custom libraries for Lyzr Automata.
Loads environment variables using load_dotenv (likely containing the OpenAI API key).
load_dotenv() is called to load environment variables from a .env file (likely containing your OpenAI API key).
api = os.getenv("OPENAI_API_KEY") retrieves the API key from the environment variable.

OpenAI Model Setup:

open_ai_text_completion_model = OpenAIModel(
    api_key=api,
    parameters={
        "model": "gpt-4-turbo-preview",
        "temperature": 0.2,
        "max_tokens": 1500,
    },
)

The OpenAIModel class from lyzr_automata is used to create an instance of the OpenAI text completion model (open_ai_text_completion_model).
It sets the API key, model name ("gpt-4-turbo-preview"), temperature (0.2), and maximum output length (1500 tokens).

User Input:

query=st.text_area("Enter your conversation: ")

query: Creates a text area for the user to input their conversation prompt.

Neurology Consultation Function:

def neurology_consult(query):

    neurology_agent = Agent(
            role="Neurology expert",
            prompt_persona=f"You are an Expert neurologist.your task is to create medical note from {query}."
        )

    neurology_task = Task(
        name="Neurology Consult",
        model=open_ai_text_completion_model,
        agent=neurology_agent,
        instructions=prompt,
    )

    output = LinearSyncPipeline(
        name="Neurology Consult Pipline",
        completion_message="pipeline completed",
        tasks=[
              neurology_task
        ],
    ).run()

    answer = output[0]['task_output']

    return answer

def neurology_consult(query):: Defines a function neurology_consult that takes query as input.
Agent Definition:
neurology_agent = Agent(...): Creates an Agent object with the following properties:
role: Sets the agent's role to "Neurology expert".
prompt_persona: Defines the agent's persona using a prompt string, indicating its task is to create a medical note based on the query.
Task Definition:
neurology_task = Task(...): Creates a Task object with the following properties:
name: Sets the task name to "Neurology Consult".
model: Sets the model to use (the open_ai_text_completion_model created earlier)
Conversation Pipeline:
LinearSyncPipeline(...): Creates a LinearSyncPipeline object, likely from lyzr_automata, which manages the conversation flow between the user and the neurology agent.
name: Sets the pipeline name to "Neurology Consult Pipline".
completion_message: Sets the message displayed when the pipeline finishes ("pipeline completed").
tasks: Defines a list of tasks within the pipeline, in this case, it only has one task:
neurology_task: The previously defined task for the neurology consultation.
.run(): Executes the LinearSyncPipeline, running the neurology consultation task.

Output:

if st.button("Consult"):
    solution = neurology_consult(query)
    st.markdown(solution)

if st.button("Consult"):: Creates a button labeled "Consult". When the button is clicked, the following code executes.
solution = neurology_consult(query): Calls the neurology_consult function with the user's input (query) and stores the generated medical note in the solution variable.
st.markdown(solution): Displays the generated medical note as formatted markdown text in the Streamlit app.

try it now: https://lyzr-neurology-consultant.streamlit.app/
For more information explore the website: Lyzr

...

🔧 Consult with AI Neurologist with Lyzr Automata, Streamlit and OpenAI


📈 123.24 Punkte
🔧 Programmierung

🔧 Building a Loan Underwriting Expert with Lyzr Automata,Streamlit and OpenAI


📈 65.88 Punkte
🔧 Programmierung

🔧 Building an Error Resolution App with Lyzr Automata,Streamlit and OpenAI


📈 65.88 Punkte
🔧 Programmierung

🔧 Simplify Your System Design Process with Lyzr Automata,OpenAI and Streamlit


📈 65.88 Punkte
🔧 Programmierung

🔧 Building an HTML to ReactJS Converter with Streamlit and Lyzr Automata


📈 57.72 Punkte
🔧 Programmierung

🔧 Automate Legal Contract Generation with Streamlit and Lyzr Automata


📈 57.72 Punkte
🔧 Programmierung

🔧 Building an Elearning Course Creator with Streamlit and Lyzr Automata


📈 57.72 Punkte
🔧 Programmierung

🔧 Automating Twitter Engagement with Lyzr Automata and Streamlit


📈 57.72 Punkte
🔧 Programmierung

🔧 Automating Product Description Generation with Lyzr Automata and OpenAI


📈 47.88 Punkte
🔧 Programmierung

🔧 Generate Chapter Notes with Lyzr ChatAgent,Summarizer,OpenAI and Streamlit


📈 47.37 Punkte
🔧 Programmierung

🔧 Designing Interior Using Lyzr Automata and Dalle 3


📈 39.72 Punkte
🔧 Programmierung

🔧 Generative AI Dataset Generator App with Streamlit and Lyzr


📈 39.21 Punkte
🔧 Programmierung

🔧 Building a Policy Information Chatbot with Streamlit and Lyzr


📈 39.21 Punkte
🔧 Programmierung

🔧 Building a Travel Advisor App with Lyzr and Streamlit


📈 39.21 Punkte
🔧 Programmierung

🔧 Building an Answer Scoring Agent with Lyzr ChatAgent and Streamlit


📈 39.21 Punkte
🔧 Programmierung

📰 Lyzr Automata: A Low-Code Multi-Agent Framework for Advanced Process Automation


📈 38.05 Punkte
🔧 AI Nachrichten

🔧 AI-Powered Privacy: Lyzr Automata’s Impact on Policy Formulation


📈 38.05 Punkte
🔧 Programmierung

🔧 Building Book Recommendation Assistant with Lyzr Automata


📈 38.05 Punkte
🔧 Programmierung

🔧 Building a Mood Analyzer App with Lyzr Automata


📈 38.05 Punkte
🔧 Programmierung

🔧 Building a Skin Care Assistant with Lyzr Automata


📈 38.05 Punkte
🔧 Programmierung

🔧 A Smart Contract Generator for Web3 Projects using Lyzr Automata


📈 38.05 Punkte
🔧 Programmierung

🔧 Automate Your Cover Letter Writing Process with Lyzr Automata


📈 38.05 Punkte
🔧 Programmierung

🔧 Building a Personalized Playlist Generator with Lyzr Automata


📈 38.05 Punkte
🔧 Programmierung

🔧 Lyzr-Automata powered README Generation


📈 38.05 Punkte
🔧 Programmierung

🔧 Optimizing Classroom Time: Using Lyzr-Automata to Generate Effective Timetables


📈 38.05 Punkte
🔧 Programmierung

🔧 Building an Automated Test Cases Generator with Lyzr Automata


📈 38.05 Punkte
🔧 Programmierung

🔧 Get Hired Faster: How to use Lyzr-Automata to draft personalised cold emails


📈 38.05 Punkte
🔧 Programmierung

📰 Lyzr Automata: A Low-Code Multi-Agent Framework for Advanced Process Automation


📈 38.05 Punkte
🔧 AI Nachrichten

📰 Streamlit from Scratch: Build a Data Dashboard with Streamlit's Layout and UI features


📈 37.67 Punkte
🔧 AI Nachrichten

📰 How to Use Streamlit’s st.write Function to Improve Your Streamlit Dashboard


📈 36.01 Punkte
🔧 AI Nachrichten

📰 The Streamlit Colour Picker: An Easy Way to Change Chart Colours on Your Streamlit Dashboard


📈 36.01 Punkte
🔧 AI Nachrichten

🔧 Building Your Construction Planner App with Lyzr and OpenAI


📈 29.37 Punkte
🔧 Programmierung

🔧 Building an AI-Powered Product Scheduler using Lyzr and OpenAI


📈 29.37 Punkte
🔧 Programmierung

🔧 Building a WhatsApp Customer Service Representative with Lyzr, Flask, Twilio, and OpenAI


📈 29.37 Punkte
🔧 Programmierung

🔧 Pre-Cloud Development Chatbot with Streamlit, Langchain, OpenAI and MongoDB Atlas Vector Search


📈 27.83 Punkte
🔧 Programmierung

matomo