run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
36.48k stars 5.21k forks source link

support single and multiturn {messages} for GPTChat API #586

Closed fredzannarbor closed 1 year ago

fredzannarbor commented 1 year ago

Please provide seamless interface to gpt-3.5-turbo

https://platform.openai.com/docs/guides/chat/introduction

openai sample code:

# Note: you need to be using OpenAI Python v0.27.0 for the code below to work
import openai

openai.ChatCompletion.create(
  model="gpt-3.5-turbo",
  messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Who won the world series in 2020?"},
        {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
        {"role": "user", "content": "Where was it played?"}
    ]
)
jerryjliu commented 1 year ago

@fredzannarbor we support using the chatgpt interface as a raw predictor here: https://github.com/jerryjliu/gpt_index/pull/584

did you have something else in mind? we don't inherently support general chatbot functionality yet but would be curious to hear your thoughts on where this could help

guyko81 commented 1 year ago

I wanted to build an index-based chatbot, where the user can continuously ask about the document, in the style of GPTSimpleVectorIndex

index = GPTSimpleVectorIndex.load_from_disk('index.json') response = index.query(text, response_mode="compact")

is that already possible?

jerryjliu commented 1 year ago

yeah! maybe try plugging in the index in a langchain agent? https://gpt-index.readthedocs.io/en/latest/how_to/using_with_langchain.html

guyko81 commented 1 year ago

absolutely, I did it, but I wanted to use chatGPT directly, instead of building up one - I thought it might create conversations that I can drive more directly. Anyway, that's definitely a good alternative, already doing it!

jerryjliu commented 1 year ago

the chatgpt api requires you to pass in all conversation history in each API request, so it's not different than previous API's in that sense (e.g. davinci). the only difference here is being able to break stuff up into messages.

for building your own chatbot, a llamaindex + langchain approach is oftentimes a good bet