https://retellai.com/?utm_source=discord&utm_medium=seo logo
internal server error on create knowledge base by ...
# ❓・bug-report
z
i have some error when i try to create knowledge base, i checked all fields and its correctly, that is my request body: { "knowledge_base_name": "1234", "knowledge_base_texts": [ {"title": "fjdakjfa", "text": "jlkadfjlksj"} ], "knowledge_base_urls": [ "https://dashboard.retellai.com/knowledgeBase?knowledge_base_id=knowledge_base_25bda4e82ee45d51" ] } and i get this error with 500 status code: { "status": "error", "message": "Internal Server Error" } endpoint url: https://api.retellai.com/create-knowledge-base
i found few tickets with same problem, but no one hasn`t solved
s
Hi @zonvimar thanks for reaching out retell team is working on knowledge base issue. Thank you
r
@shahretell : I am facing the same issue (500 Internal Server Error) using "knowledge_base_files". Is there a resolution yet?
@zonvimar : Were you able to resolve the issue?
o
What error are you facing ?
do you still face this problem ? and what are you using to send this request?
r
@Omar Ashraf | Community Lead I am trying to add sources to an existing knowledge base and getting the below error: { "message": "Request failed with status code 500", "name": "AxiosError", "code": "ERR_BAD_RESPONSE", "status": 500 } Here my code snippet for your reference: let form = new FormData(); form.append( "knowledge_base_files", fs.createReadStream(
/tmp/${filenameOutput}
) ); const add_kb_response = await axios.post(
https://api.retellai.com/add-knowledge-base-sources/${knowledgeBaseResponses[0].knowledge_base_id}
, form, { headers: { ...form.getHeaders(), Authorization:
Bearer ${process.env.RETELL_API_KEY}
, }, } );
o
Try this one
`import Retell from 'retell-sdk'; import fs from 'fs'; const client = new Retell({ apiKey: 'Key', }); async function main() { try { const formData = new FormData(); const fileContent = fs.readFileSync('./test.txt'); const fileBlob = new Blob([fileContent], { type: 'text/plain' }); formData.append('knowledge_base_name', 'KB_Name'); formData.append('knowledge_base_files', fileBlob, 'FILE_NAME.txt'); // put the file path const response = await fetch('https://api.retellai.com/create-knowledge-base', { method: 'POST', headers: { 'Authorization':
Bearer ${client.apiKey}
, }, body: formData, }); if (!response.ok) { const errorText = await response.text(); console.error('Error creating knowledge base:', errorText); return; } const result = await response.json(); console.log('Knowledge base created successfully:', result); } catch (error) { console.error('Error:', error); } } main();`
r
Thanks @Omar Ashraf | Community Lead . Unfortunately, now I am getting a different error. Error creating knowledge base: {"status":"error","message":"knowledge base name not a string"} I have double checked that I have the "knowledge_base_name" appended to the form data and it is a string. formData.append( "knowledge_base_name", knowledgeBaseResponses[0].knowledge_base_name );
o
Put your variable inside ` ``${var}`` `
r
Still the same the error after using template literal. btw the variable is already a string which I verified using typeof. formData.append( "knowledge_base_name",
${knowledgeBaseResponses[0].knowledge_base_name}
);
o
can you try to use normal string instead of the variable just for testing because i can't reproduce the problem
s
@Omar Ashraf | Community Lead i keep getting 500 internal server error when cretaing knowledge base const formData = new FormData(); formData.append('knowledge_base_name', 'simple KB'); const response = await fetch(
${RETELL_API_BASE}/create-knowledge-base
, { method: 'POST', headers: { 'Authorization':
Bearer ${this.apiKey}
, }, body: formData, }); if (!response.ok) { const error = await response.text(); throw new Error(
Failed to create knowledge base: ${error}
); } return response.json(); Error occurred: Message: Failed to create knowledge base: {"status":"error","message":"Internal Server Error"} Stack: Error: Failed to create knowledge base: {"status":"error","message":"Internal Server Error"}
o
Hello @sekharm_95325 , for Knowledge base you will have to use the SDK.
j
Hello, I'm having the same issue as @sekharm_95325 . I'm using the SDK that is in Retell Web and it doesn't work. We’re getting a 500 Internal Server Error on POST /add-knowledge-base-sources/{knowledge_base_id} for knowledge_base_id = "knowledge_base_4795920f6ddcdf66". Minimal repro using retell-sdk (Python): from retell import Retell, APIStatusErrorimport httpx client = Retell(api_key="XXXX") KB_ID = "knowledge_base_4795920f6ddcdf66"try: resp: httpx.Response = client.post( f"/add-knowledge-base-sources/{KB_ID}", body={"knowledge_base_urls": ["https://torrent.es/equipamiento/conocer-torrent/"]}, cast_to=httpx.Response, ) print(resp.status_code, resp.json())except APIStatusError as e: print(e.status_code, e.response.text) The response is always: {"status":"error","message":"Internal Server Error"}.