Skip to content

Commit

Permalink
add layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
kaifei committed Aug 26, 2024
1 parent 6a1f707 commit 0bd3b59
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

*yaml
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
remote_theme: pages-themes/[email protected]
title: tutorial-langchain
markdown: GFM
78 changes: 78 additions & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="{{ site.lang | default: en-US }}">

<head>
<meta charset="UTF-8">

{% seo %}
<link rel="icon" href="{{site.github.owner_gravatar_url}}" type="image/x-icon">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link rel="preload" href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&display=swap" as="style"
type="text/css" crossorigin>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#157878">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<link rel="stylesheet" href="{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}">
{% include head-custom.html %}
</head>

<body>
<a id="skip-to-content" href="#content">Skip to the content.</a>

<header class="page-header" role="banner">
<h1 class="project-name">{{ page.title | default: site.title | default: site.github.repository_name }}</h1>
<h2 class="project-tagline">{{ page.description | default: site.description | default: site.github.project_tagline
}}</h2>
{% if site.github.is_project_page %}
<a href="{{ site.github.url }}" class="btn">Back To HomePage</a>
{% endif %}
{% if site.show_downloads %}
<a href="{{ site.github.zip_url }}" class="btn">Download .zip</a>
<a href="{{ site.github.tar_url }}" class="btn">Download .tar.gz</a>
{% endif %}
</header>

<div class="goTop">
<a href="#" class="goTopBtn jq-goTop">
<i class="fas fa-arrow-alt-circle-up fa-3x"></i>
</a>
</div>

<main id="content" class="main-content" role="main">

{{ content }}

<footer class="site-footer">
{% if site.github.is_project_page %}
<span class="site-footer-owner"><a href="{{ site.github.repository_url }}">{{ site.github.repository_name }}</a>
is maintained by <a href="{{ site.github.owner_url }}">{{ site.github.owner_name }}</a>.</span>
{% endif %}
<span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub
Pages</a>.</span>
</footer>
</main>
</body>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- <script type="text/javascript">
$(function () {
$(window).scroll(function () {
if ($(window).scrollTop() > 200) {
if ($(".goTop").hasClass("hide")) {
$(".goTop").toggleClass("hide");
}
} else {
$(".goTop").addClass("hide");
}
});
});
</script>
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/[email protected]/+esm';
mermaid.initialize({ startOnLoad: false });
await mermaid.run({
querySelector: '.language-mermaid',
});
</script> -->

</html>
9 changes: 4 additions & 5 deletions docs/240823-chat-bot.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ RunnableWithMessageHistory 是 LangChain 中用于管理对话历史的关键类
4. `history_messages_key`: 可选,字符串,指定输出字典中存储历史消息的键名。如果不指定,历史消息将直接添加到输入消息中。
5. `output_messages_key`: 可选,字符串,指定输出字典中存储新生成消息的键名。如果不指定,新消息将直接添加到历史消息中。

>
> code: [RunnableWithMessageHistory](https://github.com/ka1fe1/tutorial-langchain/blob/main/tutorial-app/2_chat_bot.py#L67)
## Managing Chat History

管理对话历史的关键在于使用 trim_messages 来修剪消息历史,以保持对话的清晰和相关性。
Expand All @@ -29,8 +32,4 @@ trim_messages 对象有以下参数及其作用:

这些参数允许灵活地控制如何修剪和管理对话历史,以确保保留最相关的信息,同时保持历史的简洁性和效率。

## raw code

```python
https://raw.githubusercontent.com/ka1fe1/tutorial-lanchain/main/tutorial-app/2_chat_bot.py
```
> code: [ManagingConversationHistory](https://github.com/ka1fe1/tutorial-langchain/blob/main/tutorial-app/2_chat_bot.py#L124)

0 comments on commit 0bd3b59

Please sign in to comment.