mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-13 21:06:03 +08:00
fix add slef base url openai error (#1854)
### What problem does this PR solve? ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
e34817c2a9
commit
1d5a9b74ff
@ -48,7 +48,7 @@ def set_api_key():
|
|||||||
req["api_key"], llm.llm_name, base_url=req.get("base_url"))
|
req["api_key"], llm.llm_name, base_url=req.get("base_url"))
|
||||||
try:
|
try:
|
||||||
arr, tc = mdl.encode(["Test if the api key is available"])
|
arr, tc = mdl.encode(["Test if the api key is available"])
|
||||||
if len(arr[0]) == 0 or tc == 0:
|
if len(arr[0]) == 0:
|
||||||
raise Exception("Fail")
|
raise Exception("Fail")
|
||||||
embd_passed = True
|
embd_passed = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -59,7 +59,7 @@ def set_api_key():
|
|||||||
try:
|
try:
|
||||||
m, tc = mdl.chat(None, [{"role": "user", "content": "Hello! How are you doing!"}],
|
m, tc = mdl.chat(None, [{"role": "user", "content": "Hello! How are you doing!"}],
|
||||||
{"temperature": 0.9,'max_tokens':50})
|
{"temperature": 0.9,'max_tokens':50})
|
||||||
if not tc:
|
if m.find("**ERROR**") >=0:
|
||||||
raise Exception(m)
|
raise Exception(m)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg += f"\nFail to access model({llm.llm_name}) using this api key." + str(
|
msg += f"\nFail to access model({llm.llm_name}) using this api key." + str(
|
||||||
|
@ -35,7 +35,7 @@ def be_children(obj: dict, keyset:set):
|
|||||||
obj = [obj]
|
obj = [obj]
|
||||||
if isinstance(obj, list):
|
if isinstance(obj, list):
|
||||||
for i in obj: keyset.add(i)
|
for i in obj: keyset.add(i)
|
||||||
return [{"id": i, "children":[]} for i in obj]
|
return [{"id": re.sub(r"\*+", "", i), "children":[]} for i in obj]
|
||||||
arr = []
|
arr = []
|
||||||
for k,v in obj.items():
|
for k,v in obj.items():
|
||||||
k = re.sub(r"\*+", "", k)
|
k = re.sub(r"\*+", "", k)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user