Skip to content

Commit 0306fb6

Browse files
author
reidliu41
committed
auto generate help
Signed-off-by: reidliu41 <[email protected]>
1 parent dbe5db5 commit 0306fb6

File tree

3 files changed

+16
-68
lines changed

3 files changed

+16
-68
lines changed

docs/source/deployment/frameworks/retrieval_augmented_generation.md

Lines changed: 10 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -39,40 +39,11 @@ vllm serve qwen/Qwen1.5-0.5B-Chat --port 8001
3939

4040
- Use the script: <gh-file:examples/online_serving/retrieval_augmented_generation_with_langchain.py>
4141

42-
```python
43-
python retrieval_augmented_generation_with_langchain.py --help
44-
usage: retrieval_augmented_generation_with_langchain.py [-h] [--vllm-api-key VLLM_API_KEY]
45-
[--vllm-embedding-endpoint VLLM_EMBEDDING_ENDPOINT]
46-
[--vllm-chat-endpoint VLLM_CHAT_ENDPOINT]
47-
[--uri URI] [--url URL]
48-
[--embedding-model EMBEDDING_MODEL]
49-
[--chat-model CHAT_MODEL] [-i] [-k TOP_K]
50-
[-c CHUNK_SIZE] [-o CHUNK_OVERLAP]
51-
52-
RAG Demo with vLLM and langchain
53-
54-
options:
55-
-h, --help show this help message and exit
56-
--vllm-api-key VLLM_API_KEY
57-
API key for vLLM compatible services
58-
--vllm-embedding-endpoint VLLM_EMBEDDING_ENDPOINT
59-
Base URL for embedding service
60-
--vllm-chat-endpoint VLLM_CHAT_ENDPOINT
61-
Base URL for chat service
62-
--uri URI URI for Milvus database
63-
--url URL URL of the document to process
64-
--embedding-model EMBEDDING_MODEL
65-
Model name for embeddings
66-
--chat-model CHAT_MODEL
67-
Model name for chat
68-
-i, --interactive Enable interactive Q&A mode
69-
-k TOP_K, --top-k TOP_K
70-
Number of top results to retrieve
71-
-c CHUNK_SIZE, --chunk-size CHUNK_SIZE
72-
Chunk size for document splitting
73-
-o CHUNK_OVERLAP, --chunk-overlap CHUNK_OVERLAP
74-
Chunk overlap for document splitting
75-
```
42+
:::{argparse}
43+
:module: examples.online_serving.retrieval_augmented_generation_with_langchain
44+
:func: get_parser
45+
:prog: retrieval_augmented_generation_with_langchain.py
46+
:::
7647

7748
- Run the script
7849

@@ -112,34 +83,11 @@ vllm serve qwen/Qwen1.5-0.5B-Chat --port 8001
11283

11384
- Use the script: <gh-file:examples/online_serving/retrieval_augmented_generation_with_llamaindex.py>
11485

115-
```python
116-
python retrieval_augmented_generation_with_llamaindex.py --help
117-
usage: retrieval_augmented_generation_with_llamaindex.py [-h] [--url URL]
118-
[--embedding-model EMBEDDING_MODEL]
119-
[--chat-model CHAT_MODEL]
120-
[--vllm-api-key VLLM_API_KEY]
121-
[--embedding-endpoint EMBEDDING_ENDPOINT]
122-
[--chat-endpoint CHAT_ENDPOINT]
123-
[--db-path DB_PATH] [-i]
124-
125-
RAG with vLLM and LlamaIndex
126-
127-
options:
128-
-h, --help show this help message and exit
129-
--url URL URL of the document to process
130-
--embedding-model EMBEDDING_MODEL
131-
Model name for embeddings
132-
--chat-model CHAT_MODEL
133-
Model name for chat
134-
--vllm-api-key VLLM_API_KEY
135-
API key for vLLM compatible services
136-
--embedding-endpoint EMBEDDING_ENDPOINT
137-
Base URL for embedding service
138-
--chat-endpoint CHAT_ENDPOINT
139-
Base URL for chat service
140-
--db-path DB_PATH Path to Milvus database
141-
-i, --interactive Enable interactive Q&A mode
142-
```
86+
:::{argparse}
87+
:module: examples.online_serving.retrieval_augmented_generation_with_llamaindex
88+
:func: get_parser
89+
:prog: retrieval_augmented_generation_with_llamaindex.py
90+
:::
14391

14492
- Run the script
14593

examples/online_serving/retrieval_augmented_generation_with_langchain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def create_qa_chain(retriever: Any, llm: ChatOpenAI, prompt: PromptTemplate):
130130
| StrOutputParser())
131131

132132

133-
def parse_args():
133+
def get_parser() -> argparse.ArgumentParser:
134134
"""
135135
Parse command line arguments
136136
"""
@@ -180,7 +180,7 @@ def parse_args():
180180
default=200,
181181
help='Chunk overlap for document splitting')
182182

183-
return parser.parse_args()
183+
return parser
184184

185185

186186
def init_config(args: Namespace):
@@ -204,7 +204,7 @@ def init_config(args: Namespace):
204204

205205
def main():
206206
# Parse command line arguments
207-
args = parse_args()
207+
args = get_parser().parse_args()
208208

209209
# Initialize configuration
210210
config = init_config(args)

examples/online_serving/retrieval_augmented_generation_with_llamaindex.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def query_document(index: VectorStoreIndex, question: str, top_k: int):
115115
return query_engine.query(question)
116116

117117

118-
def parse_args():
118+
def get_parser() -> argparse.ArgumentParser:
119119
"""Parse command line arguments"""
120120
parser = argparse.ArgumentParser(
121121
description='RAG with vLLM and LlamaIndex')
@@ -164,12 +164,12 @@ def parse_args():
164164
default=3,
165165
help='Number of top results to retrieve')
166166

167-
return parser.parse_args()
167+
return parser
168168

169169

170170
def main():
171171
# Parse command line arguments
172-
args = parse_args()
172+
args = get_parser().parse_args()
173173

174174
# Initialize configuration
175175
config = init_config(args)

0 commit comments

Comments
 (0)