YanSte commited on
Commit
826eedf
·
1 Parent(s): a7236bb

pm bs4 when ollama

Browse files
Files changed (2) hide show
  1. lightrag/llm/ollama.py +1 -42
  2. lightrag/utils.py +8 -2
lightrag/llm/ollama.py CHANGED
@@ -1,51 +1,10 @@
1
- """
2
- Ollama LLM Interface Module
3
- ==========================
4
-
5
- This module provides interfaces for interacting with Ollama's language models,
6
- including text generation and embedding capabilities.
7
-
8
- Author: Lightrag team
9
- Created: 2024-01-24
10
- License: MIT License
11
-
12
- Copyright (c) 2024 Lightrag
13
-
14
- Permission is hereby granted, free of charge, to any person obtaining a copy
15
- of this software and associated documentation files (the "Software"), to deal
16
- in the Software without restriction, including without limitation the rights
17
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- copies of the Software, and to permit persons to whom the Software is
19
- furnished to do so, subject to the following conditions:
20
-
21
- Version: 1.0.0
22
-
23
- Change Log:
24
- - 1.0.0 (2024-01-24): Initial release
25
- * Added async chat completion support
26
- * Added embedding generation
27
- * Added stream response capability
28
-
29
- Dependencies:
30
- - ollama
31
- - numpy
32
- - pipmaster
33
- - Python >= 3.10
34
-
35
- Usage:
36
- from llm_interfaces.ollama_interface import ollama_model_complete, ollama_embed
37
- """
38
-
39
- __version__ = "1.0.0"
40
- __author__ = "lightrag Team"
41
- __status__ = "Production"
42
-
43
  import sys
44
 
45
  if sys.version_info < (3, 9):
46
  from typing import AsyncIterator
47
  else:
48
  from collections.abc import AsyncIterator
 
49
  import pipmaster as pm # Pipmaster for dynamic library install
50
 
51
  # install specific modules
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import sys
2
 
3
  if sys.version_info < (3, 9):
4
  from typing import AsyncIterator
5
  else:
6
  from collections.abc import AsyncIterator
7
+
8
  import pipmaster as pm # Pipmaster for dynamic library install
9
 
10
  # install specific modules
lightrag/utils.py CHANGED
@@ -13,13 +13,19 @@ from functools import wraps
13
  from hashlib import md5
14
  from typing import Any, Callable
15
  import xml.etree.ElementTree as ET
16
- import bs4
17
-
18
  import numpy as np
19
  import tiktoken
20
 
21
  from lightrag.prompt import PROMPTS
22
 
 
 
 
 
 
 
 
 
23
  VERBOSE_DEBUG = os.getenv("VERBOSE", "false").lower() == "true"
24
 
25
 
 
13
  from hashlib import md5
14
  from typing import Any, Callable
15
  import xml.etree.ElementTree as ET
 
 
16
  import numpy as np
17
  import tiktoken
18
 
19
  from lightrag.prompt import PROMPTS
20
 
21
+ import pipmaster as pm # Pipmaster for dynamic library install
22
+
23
+ # install specific modules
24
+ if not pm.is_installed("bs4"):
25
+ pm.install("bs4")
26
+
27
+ import bs4
28
+
29
  VERBOSE_DEBUG = os.getenv("VERBOSE", "false").lower() == "true"
30
 
31