Skip to content

Commit

Permalink
Merge pull request #11 from doccano/enhancement/demo
Browse files Browse the repository at this point in the history
Enable to input api key
  • Loading branch information
Hironsan authored Mar 19, 2023
2 parents c60a8ce + ed2c57f commit 7a2221a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion doccano_mini/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import streamlit as st
from langchain.chains import LLMChain
from langchain.llms import OpenAI
Expand Down Expand Up @@ -47,6 +49,7 @@ def task_classification(task: TaskType):
prompt.prefix = instruction

st.header("Test")
api_key = st.text_input("Enter API key", value=os.environ.get("OPENAI_API_KEY", ""))
col1, col2 = st.columns([3, 1])
text = col1.text_area(label="Please enter your text.", value="", height=300)

Expand All @@ -59,7 +62,7 @@ def task_classification(task: TaskType):
st.markdown(f"```\n{prompt.format(input=text)}\n```")

if st.button("Predict"):
llm = OpenAI(model_name=model_name, temperature=temperature, top_p=top_p) # type:ignore
llm = OpenAI(model_name=model_name, temperature=temperature, top_p=top_p, openai_api_key=api_key) # type:ignore
chain = LLMChain(llm=llm, prompt=prompt)
response = chain.run(text)
label = response.split(":")[1]
Expand Down

0 comments on commit 7a2221a

Please sign in to comment.