KevinHuSh
commited on
Commit
·
8bdf2db
1
Parent(s):
9bea9fa
resolve issure to call ZH?IPUAI (#277)
Browse files### What problem does this PR solve?
Issue link:#265
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- api/apps/conversation_app.py +4 -1
- rag/llm/chat_model.py +1 -0
- rag/nlp/query.py +1 -1
api/apps/conversation_app.py
CHANGED
@@ -360,7 +360,10 @@ def use_sql(question, field_map, tenant_id, chat_mdl):
|
|
360 |
"|" for r in tbl["rows"]]
|
361 |
if not docid_idx or not docnm_idx:
|
362 |
chat_logger.warning("SQL missing field: " + sql)
|
363 |
-
return
|
|
|
|
|
|
|
364 |
|
365 |
rows = "\n".join([r + f" ##{ii}$$ |" for ii, r in enumerate(rows)])
|
366 |
rows = re.sub(r"T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+Z)?\|", "|", rows)
|
|
|
360 |
"|" for r in tbl["rows"]]
|
361 |
if not docid_idx or not docnm_idx:
|
362 |
chat_logger.warning("SQL missing field: " + sql)
|
363 |
+
return {
|
364 |
+
"answer": "\n".join([clmns, line, rows]),
|
365 |
+
"reference": {"chunks": [], "doc_aggs": []}
|
366 |
+
}
|
367 |
|
368 |
rows = "\n".join([r + f" ##{ii}$$ |" for ii, r in enumerate(rows)])
|
369 |
rows = re.sub(r"T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+Z)?\|", "|", rows)
|
rag/llm/chat_model.py
CHANGED
@@ -117,6 +117,7 @@ class ZhipuChat(Base):
|
|
117 |
history.insert(0, {"role": "system", "content": system})
|
118 |
try:
|
119 |
if "presence_penalty" in gen_conf: del gen_conf["presence_penalty"]
|
|
|
120 |
response = self.client.chat.completions.create(
|
121 |
model=self.model_name,
|
122 |
messages=history,
|
|
|
117 |
history.insert(0, {"role": "system", "content": system})
|
118 |
try:
|
119 |
if "presence_penalty" in gen_conf: del gen_conf["presence_penalty"]
|
120 |
+
if "frequency_penalty" in gen_conf: del gen_conf["frequency_penalty"]
|
121 |
response = self.client.chat.completions.create(
|
122 |
model=self.model_name,
|
123 |
messages=history,
|
rag/nlp/query.py
CHANGED
@@ -35,7 +35,7 @@ class EsQueryer:
|
|
35 |
@staticmethod
|
36 |
def rmWWW(txt):
|
37 |
patts = [
|
38 |
-
(r"是*(
|
39 |
(r"(^| )(what|who|how|which|where|why)('re|'s)? ", " "),
|
40 |
(r"(^| )('s|'re|is|are|were|was|do|does|did|don't|doesn't|didn't|has|have|be|there|you|me|your|my|mine|just|please|may|i|should|would|wouldn't|will|won't|done|go|for|with|so|the|a|an|by|i'm|it's|he's|she's|they|they're|you're|as|by|on|in|at|up|out|down)", " ")
|
41 |
]
|
|
|
35 |
@staticmethod
|
36 |
def rmWWW(txt):
|
37 |
patts = [
|
38 |
+
(r"是*(什么样的|哪家|一下|那家|啥样|咋样了|什么时候|何时|何地|何人|是否|是不是|多少|哪里|怎么|哪儿|怎么样|如何|哪些|是啥|啥是|啊|吗|呢|吧|咋|什么|有没有|呀)是*", ""),
|
39 |
(r"(^| )(what|who|how|which|where|why)('re|'s)? ", " "),
|
40 |
(r"(^| )('s|'re|is|are|were|was|do|does|did|don't|doesn't|didn't|has|have|be|there|you|me|your|my|mine|just|please|may|i|should|would|wouldn't|will|won't|done|go|for|with|so|the|a|an|by|i'm|it's|he's|she's|they|they're|you're|as|by|on|in|at|up|out|down)", " ")
|
41 |
]
|