Skip to content

Commit

Permalink
Merge pull request #2373 from 6vision/summary_app_code
Browse files Browse the repository at this point in the history
Buy using app code, supports custom summary prompt .
  • Loading branch information
6vision authored Nov 7, 2024
2 parents 22d67b3 + 5cd2ae8 commit 9421d44
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions plugins/linkai/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ def __init__(self):
def summary_file(self, file_path: str, app_code: str):
file_body = {
"file": open(file_path, "rb"),
"name": file_path.split("/")[-1],
"name": file_path.split("/")[-1]
}
body = {
"app_code": app_code
}
url = self.base_url() + "/v1/summary/file"
res = requests.post(url, headers=self.headers(), files=file_body, timeout=(5, 300))
logger.info(f"[LinkSum] file summary, app_code={app_code}")
res = requests.post(url, headers=self.headers(), files=file_body, data=body, timeout=(5, 300))
return self._parse_summary_res(res)

def summary_url(self, url: str, app_code: str):
Expand All @@ -25,6 +28,7 @@ def summary_url(self, url: str, app_code: str):
"url": url,
"app_code": app_code
}
logger.info(f"[LinkSum] url summary, app_code={app_code}")
res = requests.post(url=self.base_url() + "/v1/summary/url", headers=self.headers(), json=body, timeout=(5, 180))
return self._parse_summary_res(res)

Expand All @@ -50,7 +54,7 @@ def summary_chat(self, summary_id: str):
def _parse_summary_res(self, res):
if res.status_code == 200:
res = res.json()
logger.debug(f"[LinkSum] url summary, res={res}")
logger.debug(f"[LinkSum] summary result, res={res}")
if res.get("code") == 200:
data = res.get("data")
return {
Expand Down

0 comments on commit 9421d44

Please sign in to comment.