|
13 | 13 | import requests |
14 | 14 | import json |
15 | 15 |
|
16 | | -#API_KEY: ragflow的apikey |
17 | | -#AGENT_ID: ragflow的agentid |
18 | | -#HOST: ragflow的host 要加http://或https://头。 |
19 | | -#PORT: ragflow的port |
| 16 | +#API_KEY: ragflow apikey |
| 17 | +#AGENT_ID: ragflow agentid |
| 18 | +#HOST: ragflow host start with http:// or https:// |
| 19 | +#PORT: ragflow port |
20 | 20 | class Pipeline: |
21 | 21 | class Valves(BaseModel): |
22 | 22 | API_KEY: str |
@@ -113,13 +113,17 @@ def pipe( |
113 | 113 | filesList=[] |
114 | 114 | for chunk in json_data['data']['reference']['chunks']: |
115 | 115 | if chunk['document_id'] not in filesList: |
116 | | - referenceStr=referenceStr+f"\n\n - ["+chunk['document_name']+f"]({self.valves.HOST}:{self.valves.PORT}/document/{chunk['document_id']}?ext=docx&prefix=document)" |
117 | | - filesList.append(chunk['document_id']) |
118 | | - print(f"chunks is :{len(json_data['data']['reference']['chunks'])}") |
119 | | - print(f"chunks is :{json_data['data']['reference']['chunks']}") |
| 116 | + filename = chunk['document_name'] |
| 117 | + parts = filename.split('.') |
| 118 | + last_part = parts[-1].strip() |
| 119 | + ext= last_part.lower() if last_part else '' |
| 120 | + referenceStr=referenceStr+f"\n\n - ["+chunk['document_name']+f"]({self.valves.HOST}:{self.valves.PORT}/document/{chunk['document_id']}?ext={ext}&prefix=document)" |
| 121 | + filesList.append(chunk['document_id']) |
| 122 | + #print(f"chunks is :{len(json_data['data']['reference']['chunks'])}") |
| 123 | + #print(f"chunks is :{json_data['data']['reference']['chunks']}") |
120 | 124 | yield referenceStr |
121 | 125 | else: |
122 | | - print(json_data['data']) |
| 126 | + #print(json_data['data']) |
123 | 127 | yield json_data['data']['answer'][step:] |
124 | 128 | step=len(json_data['data']['answer']) |
125 | 129 |
|
|
0 commit comments