Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ For this example, we will be using OpenAI’s APIs, so we need to set the enviro
export OPENAI_API_KEY="..."
```

If you want to change the model, set the environment variable in the terminal.
We use `text-davinci-003` by default.

```bash
export OPENAI_MODEL_NAME="gpt-3.5-turbo"
```

Then, we can run the server.

```bash
Expand Down
24 changes: 20 additions & 4 deletions doccano_mini/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os

import streamlit as st
from langchain.chains import LLMChain
from langchain.llms import OpenAI
Expand Down Expand Up @@ -45,9 +43,27 @@ def main():

st.header("Test")
text = st.text_area(label="Please enter your text.", value="")

st.header("Model Options")

# https://platform.openai.com/docs/models/gpt-3-5
available_models = (
"gpt-3.5-turbo",
"gpt-3.5-turbo-0301",
"text-davinci-003",
"text-davinci-002",
"code-davinci-002",
)

# Use text-davinci-003 by default.
model_name = st.selectbox("Select an OpenAI model to use.", available_models, index=2)

temperature = st.slider("Temperature", min_value=0.0, max_value=1.0, value=0.7, step=0.01)

top_p = st.slider("Top-p", min_value=0.0, max_value=1.0, value=1.0, step=0.01)

if st.button("Predict"):
model_name = os.getenv("OPENAI_MODEL_NAME", "text-davinci-003")
llm = OpenAI(model_name=model_name)
llm = OpenAI(model_name=model_name, temperature=temperature, top_p=top_p)
chain = LLMChain(llm=llm, prompt=prompt)
response = chain.run(text)
label = response.split(":")[1]
Expand Down