远兮 commited on
Commit
8532637
·
1 Parent(s): df3a5e1

add prompt layer

Browse files
Files changed (3) hide show
  1. README.md +1 -0
  2. app.py +6 -1
  3. llms_prompt_layer.ipynb +58 -0
README.md CHANGED
@@ -45,5 +45,6 @@ pip3 list
45
  TODO:
46
  1.看一下ONNXruntime
47
  2.详细看一下gptcache
 
48
 
49
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
45
  TODO:
46
  1.看一下ONNXruntime
47
  2.详细看一下gptcache
48
+ 3.看一下Hugging Face Hub上有哪些开源model,这些model大模型环境是跑在FuggingFace上的?如果要用的话,可以直接用还是自己搭server环境?
49
 
50
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -1,11 +1,16 @@
1
  import gradio as gr
2
  from langchain.llms import OpenAI
 
3
 
4
  def chatOpenAI(input):
5
  llm = OpenAI(temperature=0.9)
6
  return llm(input)
7
 
 
 
 
 
8
  with gr.Blocks() as demo:
9
  gr.Markdown("# LangChain Test,LLM跑步上车。")
10
- gr.Interface(fn=chatOpenAI, inputs="text", outputs="text")
11
  demo.launch()
 
1
  import gradio as gr
2
  from langchain.llms import OpenAI
3
+ from langchain.llms import PromptLayerOpenAI
4
 
5
  def chatOpenAI(input):
6
  llm = OpenAI(temperature=0.9)
7
  return llm(input)
8
 
9
+ def promptLayer(input):
10
+ llm = PromptLayerOpenAI(pl_tags=["LangChainGo"])
11
+ return llm(input)
12
+
13
  with gr.Blocks() as demo:
14
  gr.Markdown("# LangChain Test,LLM跑步上车。")
15
+ gr.Interface(fn=promptLayer, inputs="text", outputs="text")
16
  demo.launch()
llms_prompt_layer.ipynb ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import os\n",
10
+ "from langchain.llms import PromptLayerOpenAI\n",
11
+ "import promptlayer"
12
+ ]
13
+ },
14
+ {
15
+ "cell_type": "code",
16
+ "execution_count": 2,
17
+ "metadata": {},
18
+ "outputs": [
19
+ {
20
+ "data": {
21
+ "text/plain": [
22
+ "\" to be a dog\\n\\nThat's not very likely to happen, but if you really want to be like a dog, you could try to learn some of their behaviors. You can play fetch, go for walks, and learn basic commands. You can also try getting some of the same toys that dogs have.\""
23
+ ]
24
+ },
25
+ "execution_count": 2,
26
+ "metadata": {},
27
+ "output_type": "execute_result"
28
+ }
29
+ ],
30
+ "source": [
31
+ "llm = PromptLayerOpenAI(pl_tags=[\"langchain\"])\n",
32
+ "llm(\"I am a cat and I want\")"
33
+ ]
34
+ }
35
+ ],
36
+ "metadata": {
37
+ "kernelspec": {
38
+ "display_name": "base",
39
+ "language": "python",
40
+ "name": "python3"
41
+ },
42
+ "language_info": {
43
+ "codemirror_mode": {
44
+ "name": "ipython",
45
+ "version": 3
46
+ },
47
+ "file_extension": ".py",
48
+ "mimetype": "text/x-python",
49
+ "name": "python",
50
+ "nbconvert_exporter": "python",
51
+ "pygments_lexer": "ipython3",
52
+ "version": "3.10.10"
53
+ },
54
+ "orig_nbformat": 4
55
+ },
56
+ "nbformat": 4,
57
+ "nbformat_minor": 2
58
+ }