Kevin Hu
commited on
Commit
·
527e971
1
Parent(s):
2e1c73c
fix add slef base url openai error (#1854)
Browse files### What problem does this PR solve?
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- api/apps/llm_app.py +2 -2
- graphrag/index.py +1 -1
api/apps/llm_app.py
CHANGED
|
@@ -48,7 +48,7 @@ def set_api_key():
|
|
| 48 |
req["api_key"], llm.llm_name, base_url=req.get("base_url"))
|
| 49 |
try:
|
| 50 |
arr, tc = mdl.encode(["Test if the api key is available"])
|
| 51 |
-
if len(arr[0]) == 0
|
| 52 |
raise Exception("Fail")
|
| 53 |
embd_passed = True
|
| 54 |
except Exception as e:
|
|
@@ -59,7 +59,7 @@ def set_api_key():
|
|
| 59 |
try:
|
| 60 |
m, tc = mdl.chat(None, [{"role": "user", "content": "Hello! How are you doing!"}],
|
| 61 |
{"temperature": 0.9,'max_tokens':50})
|
| 62 |
-
if
|
| 63 |
raise Exception(m)
|
| 64 |
except Exception as e:
|
| 65 |
msg += f"\nFail to access model({llm.llm_name}) using this api key." + str(
|
|
|
|
| 48 |
req["api_key"], llm.llm_name, base_url=req.get("base_url"))
|
| 49 |
try:
|
| 50 |
arr, tc = mdl.encode(["Test if the api key is available"])
|
| 51 |
+
if len(arr[0]) == 0:
|
| 52 |
raise Exception("Fail")
|
| 53 |
embd_passed = True
|
| 54 |
except Exception as e:
|
|
|
|
| 59 |
try:
|
| 60 |
m, tc = mdl.chat(None, [{"role": "user", "content": "Hello! How are you doing!"}],
|
| 61 |
{"temperature": 0.9,'max_tokens':50})
|
| 62 |
+
if m.find("**ERROR**") >=0:
|
| 63 |
raise Exception(m)
|
| 64 |
except Exception as e:
|
| 65 |
msg += f"\nFail to access model({llm.llm_name}) using this api key." + str(
|
graphrag/index.py
CHANGED
|
@@ -35,7 +35,7 @@ def be_children(obj: dict, keyset:set):
|
|
| 35 |
obj = [obj]
|
| 36 |
if isinstance(obj, list):
|
| 37 |
for i in obj: keyset.add(i)
|
| 38 |
-
return [{"id": i, "children":[]} for i in obj]
|
| 39 |
arr = []
|
| 40 |
for k,v in obj.items():
|
| 41 |
k = re.sub(r"\*+", "", k)
|
|
|
|
| 35 |
obj = [obj]
|
| 36 |
if isinstance(obj, list):
|
| 37 |
for i in obj: keyset.add(i)
|
| 38 |
+
return [{"id": re.sub(r"\*+", "", i), "children":[]} for i in obj]
|
| 39 |
arr = []
|
| 40 |
for k,v in obj.items():
|
| 41 |
k = re.sub(r"\*+", "", k)
|