-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add role splitting in markdown processor, remove old guidance regions (…
…#34) * mdp: Add option to segment by role, remove guidance support from CompletionService.requestCompletion in favor of guidance message role * remove guidance from GAIS requestCompletion * update GAIS * update doc * Ensure both text and content are returned on all complete/chat completes * Add parseMarkdown tool, support preformat blocks in md tokenizer Update comment handling in MDP to only strip `<!---` * support comments in md tokenizer * Update Flow for md, fix `transformResponse` * update docs
- Loading branch information
1 parent
b72066f
commit f4840f6
Showing
22 changed files
with
641 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
### Guidance Region | ||
|
||
LLMs don't always give you the output you desire for your prompt. One approach to fixing | ||
this is by modifying your prompt to be more clear and adding more examples. | ||
Another standard approach is to provide some initial guidance to the model for what the response | ||
should look like, to guarantee that the model will give you output similar to that you desire. | ||
For example, instead of just asking your model to output JSON or YAML and then | ||
ending the prompt with a question for the model to answer, you might end it with | ||
a markdown code block (like <code>```yml</code>), that the LLM would then complete the | ||
body for. | ||
|
||
However, this can lead to messy code for you as you then have to prefix that guidance | ||
to the response you get from LXL. To make this easier, LXL provides a way to mark | ||
regions of your prompt as guidance. The guidance will then be automatically prepended | ||
to the model output you get from LXL. | ||
|
||
By setting a message role as `guidance`, that message will be sent as a `model` or `assistant` (depending on platform) message to the LLM and then be prepended to the response you get from LXL. | ||
|
||
Here is an example: | ||
```js | ||
const { CompletionService } = require('langxlang') | ||
const service = new CompletionService() | ||
const [response] = await service.requestChatCompletion('gemini-1.0-pro', { | ||
messages: [ | ||
{ role: 'user', message: 'Please convert this YAML to JSON:\n```yml\nhello: world\n```\n' }, | ||
{ role: 'guidance', message: '```json\n' } | ||
] | ||
}) | ||
console.log(response) // { text: '```json\n{"hello": "world"}\n' } | ||
``` | ||
|
||
Note: there can only be one guidance message and it must be the last one. You should remove | ||
it from the messages array the next call you do to requestChatCompletion. This feature works | ||
best when used with the role parsing system above. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.