-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moving logic from Azure OpenAI to the Langchain Core
putting the resolve methods in the interface, not in the embedded Resolver class updating documentation formatting added forgotten unremovable beans configuration
- Loading branch information
Showing
6 changed files
with
60 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
core/runtime/src/main/java/io/quarkiverse/langchain4j/runtime/auth/ModelAuthProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.quarkiverse.langchain4j.runtime.auth; | ||
|
||
import java.net.URI; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import jakarta.enterprise.inject.Instance; | ||
import jakarta.enterprise.inject.spi.CDI; | ||
|
||
import io.quarkiverse.langchain4j.ModelName; | ||
|
||
public interface ModelAuthProvider { | ||
String getAuthorization(Input input); | ||
|
||
interface Input { | ||
String method(); | ||
|
||
URI uri(); | ||
|
||
Map<String, List<Object>> headers(); | ||
} | ||
|
||
static Optional<ModelAuthProvider> resolve(String modelName) { | ||
Instance<ModelAuthProvider> beanInstance = modelName == null | ||
? CDI.current().select(ModelAuthProvider.class) | ||
: CDI.current().select(ModelAuthProvider.class, ModelName.Literal.of(modelName)); | ||
|
||
//get the first one without causing a bean1 resolution exception | ||
ModelAuthProvider authorizer = null; | ||
for (var handle : beanInstance.handles()) { | ||
authorizer = handle.get(); | ||
break; | ||
} | ||
return Optional.ofNullable(authorizer); | ||
} | ||
|
||
static Optional<ModelAuthProvider> resolve() { | ||
return resolve(null); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters