Skip to content

Commit 65e52a3

Browse files
📝
1 parent 3fd73e4 commit 65e52a3

File tree

5 files changed

+83
-77
lines changed

5 files changed

+83
-77
lines changed

docs/docs/云原生开发/接口认证.md

Lines changed: 15 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
---
22
sidebar_position: 4
3-
title: 接口认证
3+
title: 接口开发
44
---
55

66
API(应用程序编程接口)是一组规则,用于定义应用程序或设备如何相互连接和通信。
77

8-
最常用的是 REST API,它是一种使用 HTTP 请求访问和使用数据的技术
8+
接口开发分为接口规范与技术实现
99

10-
GraphQL 是一种新兴的 API 技术,它提供了一种更高效、强大和灵活的选择。
1110

12-
## REST
11+
## 接口规范:REST API
1312

1413
REST API 是符合 REST(表述性状态转移)架构样式设计原则的 API。 因此,REST API 有时被称为 RESTful API。
1514

@@ -26,7 +25,16 @@ EST API 几乎可以使用任何编程语言进行开发,并支持多种数据
2625
> 任何特定时刻或时间戳的资源状态称为资源表示。 几乎可以采用任何格式将该信息传递到客户端,包括 JavaScript 对象表示法 (JSON)、HTML、XLT、Python、PHP 或纯文本。 JSON 非常受欢迎,因为它可以被人类和机器读取,而且与编程语言无关。
2726
> 在 REST API 调用中,请求头和参数也很重要,因为它们包含重要的标识信息,例如元数据、授权、统一资源标识符 (URI)、缓存、cookie 等。 在精心设计的 REST API 中会使用请求头、响应头和常规 HTTP 状态码。
2827
29-
### 怎么使用 REST风格的API?
28+
## 技术实现
29+
30+
目前后端开发常用的轻量接口框架有:
31+
32+
- flask
33+
- FastAPI
34+
35+
如果需要开发一个复杂的业务接口,可以考虑Django。
36+
37+
### FastAPI
3038

3139
```python showLineNumbers
3240
from fastapi import FastAPI
@@ -51,9 +59,9 @@ if __name__ == "__main__":
5159
uvicorn.run(app, host="0.0.0.0", port=6022)
5260
```
5361

54-
### FastAPI示例
62+
### flask
5563

56-
FastAPI 除了可以传输文本数据,还可传输图片、视频等数据,cv2 可以捕获屏幕,将两者结合起来,实现内网直播功能,可以在局域网内通过浏览器观看屏幕共享。
64+
flask 除了可以传输文本数据,还可传输图片、视频等数据,cv2 可以捕获屏幕,将两者结合起来,实现内网直播功能,可以在局域网内通过浏览器观看屏幕共享。
5765

5866
```python showLineNumbers
5967
import os
@@ -218,73 +226,3 @@ if __name__ == '__main__':
218226
ip_host2 = '0.0.0.0'# 内网ip地址
219227
app.run(threaded=True, host=ip_host2, port=80)
220228
```
221-
222-
## Graphql
223-
224-
graphql 是一种用于 API 的查询语言,对你的 API 中的数据提供了一套易于理解的完整描述,使得客户端能够准确地获得它需要的数据,减少数据的冗余,系统中的所有入口点(REST、GraphQL 和 RPC)都将使用相同的验证、授权和错误处理规则进行处理。
225-
226-
GraphQL 同样支持 Relay, Django, SQLAlchemy, Google App Engine.
227-
228-
### 怎么使用 Graphql风格的API?
229-
230-
安装对应的模块
231-
232-
```bash showLineNumbers
233-
pip install graphene
234-
pip install strawberry-graphql
235-
pip install ariadne
236-
```
237-
238-
在 py 文件中可以运行这个简单的示例
239-
240-
```bash showLineNumbers
241-
import graphene
242-
243-
class Query(graphene.ObjectType):
244-
hello = graphene.String(name=graphene.String(default_value="World"))
245-
246-
def resolve_hello(self, info, name):
247-
return 'Hello ' + name
248-
249-
schema = graphene.Schema(query=Query)
250-
result = schema.execute('{ hello }')
251-
print(result.data['hello']) # "Hello World"
252-
```
253-
254-
### graphene示例
255-
256-
```python showLineNumbers
257-
import graphene
258-
259-
# 定义 Person 类型
260-
class Person(graphene.ObjectType):
261-
id = graphene.ID()
262-
name = graphene.String()
263-
age = graphene.Int()
264-
265-
# 定义查询类型
266-
class Query(graphene.ObjectType):
267-
# 定义查询字段,用于获取所有人的信息
268-
all_people = graphene.List(Person)
269-
270-
# 实现查询字段的解析器
271-
def resolve_all_people(self, info):
272-
# 在这个简单的例子中,我们返回一个包含一些硬编码数据的人员列表
273-
return [
274-
Person(id=1, name="John Doe", age=30),
275-
Person(id=2, name="Jane Smith", age=25),
276-
Person(id=3, name="Bob Johnson", age=35),
277-
]
278-
279-
# 创建 schema,将 Query 类型添加到根 schema 中
280-
schema = graphene.Schema(query=Query)
281-
282-
# 通过 GraphQL 查询获取结果
283-
query_string = '{ allPeople { id name age } }'
284-
result = schema.execute(query_string)
285-
286-
# 打印结果
287-
print(result.data)
288-
# {'allPeople': [{'id': '1', 'name': 'John Doe', 'age': 30}, {'id': '2', 'name': 'Jane Smith', 'age': 25}, {'id': '3', 'name': 'Bob Johnson', 'age': 35}]}
289-
```
290-
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
sidebar_position: 3
3+
title: 🚧Agent智能体
4+
---
5+
6+
## 低代码
7+
8+
扣子
9+
10+
## 纯代码
11+
12+
Langchian
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
sidebar_position: 4
3+
title: 🚧大语言模型部署
4+
---
5+
6+
-
7+
8+
9+
<DocCardList />
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
sidebar_position: 1
3+
title: 🚧大语言模型获取
4+
---
5+
6+
## 开源社区
7+
8+
社区具有明显的马太效应,即头部效应明显,头部模型拥有最多的资源,最新的技术,最多的用户。这里列举两个在国内外有一定影响力的社区。
9+
10+
### Hugging Face
11+
12+
### 魔搭社区(阿里达摩院)
13+
14+
## 商用接口
15+
16+
商业接口非常多,各有千秋,且更新迭代非常快。这里列举一个国内的接口与一个国外的接口用作示例。
17+
18+
### 百度
19+
20+
### OpenAI
21+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
sidebar_position: 1
3+
title: 🚧模型微调与部署
4+
---
5+
6+
## 模型微调
7+
8+
### LLaMA-Factory
9+
10+
## 提示词工程
11+
12+
### Prompt Engineering Guide
13+
14+
## 模型部署
15+
16+
### ollma
17+
18+
吃内存提供高并发
19+
20+
### vllma
21+
22+
吃显存提供低延迟
23+
24+
### llama-cpp-python
25+
26+
通过C重写并量化,解决了模型太大,无法加载的问题。

0 commit comments

Comments
 (0)