buhe / HtmlSummary

SwiftUI app based on langchain-swift.
GNU General Public License v3.0
3 stars 0 forks source link

Html Summary

SwiftUI app based on langchain-swift.

If you find it troublesome or want to support me, go to https://apps.apple.com/us/app/ai-pagily/id6452588389

Get started

Edit it: https://github.com/buhe/HtmlSummary/blob/main/ShareExt/env.txt , set your openai_key.

Core Code

  let loader = HtmlLoader(html: plain, url: url)
  let doc = await loader.load()
  let p = """
以下はページの内容です:%@、100語以内のメインコンテンツを要約してください。
"""
  let prompt = PromptTemplate(input_variables: ["youtube"], template: p)
  let request = prompt.format(args: [String(doc.first!.page_content.prefix(2000))])
  let llm = OpenAI()
  let reply = await llm.send(text: request)