LLMCheatsheets.jl เป็นแพ็คเกจ Julia ที่ทำให้การสอนโมเดล AI เกี่ยวกับแพ็คเกจและที่เก็บใหม่เป็นเรื่องง่ายและทันทีโดยการสร้างสูตรโกงจากที่เก็บ GitHub เครื่องมือนี้เชื่อมช่องว่างระหว่างเอกสารที่มนุษย์อ่านได้กับการนำเสนอความรู้ที่เป็นมิตรต่อ AI ช่วยให้สามารถบูรณาการเข้ากับโมเดลภาษาและผู้ช่วย AI ได้อย่างราบรื่น
ตามค่าเริ่มต้น เราจะนำชุดย่อยของโฟลเดอร์และไฟล์ในพื้นที่เก็บข้อมูลที่ให้มาและสรุปโดยใช้ LLM ให้เป็นแผ่นข้อมูลเดียว
หากต้องการติดตั้ง LLMCheatsheets.jl ให้ใช้ตัวจัดการแพ็คเกจ Julia และ repo URL (ยังไม่ได้ลงทะเบียน):
using Pkg
Pkg . add (url = " https://github.com/svilupp/LLMCheatsheets.jl " )
เคล็ดลับ
หากคุณพบขีดจำกัดอัตราเมื่อเข้าถึง GitHub API คุณสามารถตั้งค่าโทเค็นการเข้าถึงส่วนบุคคลและตั้งค่าเป็นตัวแปรสภาพแวดล้อม GITHUB_API_KEY
เพื่อเพิ่มขีดจำกัดคำขอของคุณเป็น 5,000 ต่อชั่วโมง
ต่อไปนี้คือตัวอย่างพื้นฐานของวิธีใช้ LLMCheatsheets.jl เพื่อสร้างสูตรโกงสำหรับพื้นที่เก็บข้อมูล GitHub
using LLMCheatsheets
repo = GitHubRepo ( " https://github.com/svilupp/PromptingTools.jl " )
create_cheatsheet (repo; save_path = true );
ด้วย save_path = true
cheatsheet จะถูกบันทึกลงในโฟลเดอร์ llm-cheatsheets
ในไดเร็กทอรีการทำงานปัจจุบัน
จะเกิดอะไรขึ้นเบื้องหลัง:
repo.paths
และ repo.file_types
สำหรับอินเทอร์เฟซระดับต่ำเพื่อสร้างไฟล์ทีละไฟล์และประมวลผลด้วยตนเอง โปรดดูที่ examples/create_for_promptingtools.jl
บางครั้งคุณอาจต้องการดาวน์โหลดไฟล์โดยไม่ต้องสรุป คุณสามารถทำได้ด้วยฟังก์ชั่น collect
files_str = collect (repo)
files_str
จะเป็นสตริงที่มีไฟล์สแกนทั้งหมดต่อกัน หากต้องการใช้ใน ChatGPT หรือ Claude.ai ให้ใช้ฟังก์ชัน clipboard
เพื่อคัดลอกไปยังคลิปบอร์ด - files_str|>clipboard
ตามค่าเริ่มต้น ไฟล์ที่สแกนและดาวน์โหลดคือ repo.paths
และ repo.file_types
ตามลำดับ
ตามค่าเริ่มต้น repo.paths
จะรวม ["src", "docs/src", "README.md"]
และ repo.file_types
รวมถึง [".jl", ".md"]
คุณสามารถปรับแต่งสิ่งเหล่านี้ได้เมื่อสร้างออบเจ็กต์ GitHubRepo
:
เช่น เพิ่ม examples
โฟลเดอร์และไฟล์ .txt
เพื่อปรับแต่งสิ่งที่เราจะสรุป:
repo = GitHubRepo ( " https://github.com/username/repository " ; paths = [ " examples " , " README.md " ], file_types = [ " .jl " , " .md " , " .txt " ])
คุณสามารถใช้ LLM อื่นได้โดยส่งอาร์กิวเมนต์ model
ไปยังฟังก์ชัน
create_cheatsheet (repo; save_path = true , model = " gpt4om " )
คุณสามารถให้คำแนะนำพิเศษเพื่อเป็นแนวทางแก่ AI ในการสร้างสูตรโกงได้:
create_cheatsheet (repo; special_instructions = " Focus on the data structures and their interactions. " )
คุณสามารถส่งออกฟังก์ชัน ai* จาก PromptingTools.jl เพื่อใช้กับ LLMCheatsheets.jl ได้
using LLMCheatsheets
# Re-export aigenerate, pprint from PromptingTools
using LLMCheatsheets : aigenerate, pprint
# Or import PromptingTools directly
# using PromptingTools
repo = GitHubRepo ( " https://github.com/svilupp/PromptingTools.jl " ; paths = [ " docs/src " , " README.md " ])
files_str = collect (repo)
msg = aigenerate ( " Read through these files: $(files_str) nn Answer the question: What is the function for creating prompt templates? " )
pprint (msg)
The function for creating prompt templates in the `PromptingTools.jl` package is `create_template`. This function allows you to define a prompt with placeholders and save it for later use. The syntax is:
```julia
create_template(; user=<user prompt>,
system=<system prompt>, load_as=<template name>)
```
This function generates a vector of messages, which you can use directly in the `ai*` functions. If you provide the `load_as` argument, it will also register the template in the template store,
allowing you to access it later using its name.
หากคุณได้รับการจำกัดอัตราโดยผู้ให้บริการ LLM คุณสามารถลดจำนวนงานสรุปที่เกิดขึ้นพร้อมกันใน create_cheatsheet
ได้โดยตั้งค่าตัวเลขให้ต่ำลง เช่น ntasks=5
หรือ ntasks=2
(ขึ้นอยู่กับระดับ API ของคุณ)
ตั้งค่าโทเค็นการเข้าถึงส่วนบุคคลและตั้งเป็น ENV["GITHUB_API_KEY"]
มันจะถูกโหลดลงในตัวแปร LLMCheatsheets.GITHUB_API_KEY
โดยอัตโนมัติ
คุณสามารถตั้งค่าโทเค็นการเข้าถึงส่วนบุคคลสำหรับ GitHub API ได้โดยทำตามขั้นตอนเหล่านี้:
จากนั้นคุณสามารถตั้งค่าเป็น ENV["GITHUB_API_KEY"]
หรือ LLMCheatsheets.GITHUB_API_KEY
สำหรับข้อมูลเพิ่มเติมเกี่ยวกับการใช้ LLMCheatsheets.jl โปรดดูที่เอกสารประกอบ
หากคุณพบปัญหาหรือมีคำถาม โปรดเปิดปัญหาบนพื้นที่เก็บข้อมูล GitHub