Find answers from the community

Home
Members
kaandikbas
k
kaandikbas
Offline, last seen 3 months ago
Joined September 25, 2024
hi i am new to python and i need your help on something.

I want to make a chatbot using my own data but it always uses the text-davinci model, how can I change this model?

I am sending the code. thanks

Code :

import openai
from llama_index import VectorStoreIndex, SimpleDirectoryReader, Document, StorageContext, load_index_from_storage
import os

os.environ['OPENAI_API_KEY'] = 'token'
openai.api_key = os.environ['OPENAI_API_KEY']

documents = SimpleDirectoryReader('textFiles').load_data()

text_list = [documents[0].text]
documents = [Document(t) for t in text_list]

index = VectorStoreIndex.from_documents(documents)

index.storage_context.persist()

storage_context = StorageContext.from_defaults(persist_dir="./storage")
index = load_index_from_storage(storage_context)
query_engine = index.as_query_engine()

while True:
user_input = input("Please enter a question: ")
if user_input.lower() == 'exit':
break
response = query_engine.query(user_input)
print(response)
6 comments
k
L
from llama_index.llms import OpenAI
llm = OpenAI(temperature=0, model="text-davinci-002")
service_context = ServiceContext.from_defaults(llm=llm)

When I use this example from the doc I get the following error: how can I solve it?
File "main.py", line 5, in <module>
from llama_index.llms import OpenAI
ModuleNotFoundError: There is no module named 'llama_index.llms'
2 comments
L